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
- Author:
- Jason Dillon
-
Nested Class Summary
Nested classes/interfaces inherited from interface History
History.Entry -
Field Summary
Fields inherited from class 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 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface 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 Iterable
forEach, spliterator
-
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
-