public class DataFile extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
class |
DataFile.DataIterator
An iterator that iterates over the data that is stored in a data file.
|
Constructor and Description |
---|
DataFile(File file) |
DataFile(File file,
boolean forceSync) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Discards all stored data.
|
void |
close()
Closes the data file, releasing any file locks that it might have.
|
byte[] |
getData(long offset)
Gets the data that is stored at the specified offset.
|
File |
getFile() |
DataFile.DataIterator |
iterator()
Gets an iterator that can be used to iterate over all stored data.
|
long |
storeData(byte[] data)
Stores the specified data and returns the byte-offset at which it has been stored.
|
void |
sync()
Syncs any unstored data to the hash file.
|
public DataFile(File file) throws IOException
IOException
public DataFile(File file, boolean forceSync) throws IOException
IOException
public File getFile()
public long storeData(byte[] data) throws IOException
data
- The data to store, must not be null.IOException
public byte[] getData(long offset) throws IOException
offset
- An offset in the data file, must be larger than 0.IOException
- If an I/O error occurred.public void clear() throws IOException
IOException
- If an I/O error occurred.public void sync() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public DataFile.DataIterator iterator()
Copyright © 2015-2019 Eclipse Foundation. All Rights Reserved.