Package jline.console.history
Class FileHistory
java.lang.Object
jline.console.history.MemoryHistory
jline.console.history.FileHistory
- All Implemented Interfaces:
Flushable,Iterable<History.Entry>,History,PersistentHistory
History using a file for persistent backing.
Implementers should install shutdown hook to call flush()
to save history to disk.- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface jline.console.history.History
History.Entry -
Field Summary
FieldsFields inherited from class jline.console.history.MemoryHistory
DEFAULT_MAX_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionFileHistory(File file) Load a history file into memory, truncating to default max size.FileHistory(File file, boolean doInit) Create a FileHistory, but only initialize if doInit is true. -
Method Summary
Methods inherited from class jline.console.history.MemoryHistory
add, clear, current, entries, entries, get, getMaxSize, index, internalAdd, isAutoTrim, isEmpty, isIgnoreDuplicates, iterator, moveTo, moveToEnd, moveToFirst, moveToLast, next, previous, remove, removeFirst, removeLast, replace, set, setAutoTrim, setIgnoreDuplicates, setMaxSize, size, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jline.console.history.History
add, clear, current, entries, entries, get, index, isEmpty, iterator, moveTo, moveToEnd, moveToFirst, moveToLast, next, previous, remove, removeFirst, removeLast, replace, set, sizeMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
file
-
-
Constructor Details
-
FileHistory
Load a history file into memory, truncating to default max size.- Throws:
IOException
-
FileHistory
Create a FileHistory, but only initialize if doInit is true. This allows setting maxSize or other settings; call load() before using if doInit is false.- Throws:
IOException
-
-
Method Details
-
load
Load history from file, e.g. if using delayed init.- Throws:
IOException
-
getFile
-
load
- Throws:
IOException
-
load
- Throws:
IOException
-
load
- Throws:
IOException
-
flush
Description copied from interface:PersistentHistoryFlush all items to persistent storage.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfacePersistentHistory- Throws:
IOException- Flush failed
-
purge
Description copied from interface:PersistentHistoryPurge persistent storage andHistory.clear().- Specified by:
purgein interfacePersistentHistory- Throws:
IOException- Purge failed
-