public class FileHistory extends MemoryHistory implements PersistentHistory, Flushable
History
using a file for persistent backing.
Implementers should install shutdown hook to call flush()
to save history to disk.History.Entry
DEFAULT_MAX_SIZE
Constructor and Description |
---|
FileHistory(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.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flush all items to persistent storage.
|
File |
getFile() |
void |
load()
Load history from file, e.g.
|
void |
load(File file) |
void |
load(InputStream input) |
void |
load(Reader reader) |
void |
purge()
Purge persistent storage and
History.clear() . |
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, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, clear, current, entries, entries, get, index, isEmpty, iterator, moveTo, moveToEnd, moveToFirst, moveToLast, next, previous, remove, removeFirst, removeLast, replace, set, size
forEach, spliterator
public FileHistory(File file) throws IOException
IOException
public FileHistory(File file, boolean doInit) throws IOException
IOException
public void load() throws IOException
IOException
public File getFile()
public void load(File file) throws IOException
IOException
public void load(InputStream input) throws IOException
IOException
public void load(Reader reader) throws IOException
IOException
public void flush() throws IOException
PersistentHistory
flush
in interface Flushable
flush
in interface PersistentHistory
IOException
- Flush failedpublic void purge() throws IOException
PersistentHistory
History.clear()
.purge
in interface PersistentHistory
IOException
- Purge failedCopyright © 2024. All rights reserved.