public class FileBuffer extends AbstractBuffer
Constructor and Description |
---|
FileBuffer(String path,
String mode)
Default constructor allowing to pass in a non-"rw" file mode.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the buffer, cleaning up file state.
|
void |
flush(boolean includeMetadata)
Flush the buffer, writing any pending content to the underlying storage device,
optionally also the file's metadata.
|
int |
read(ByteBuffer dst)
Delegates to
FileChannel |
int |
read(ByteBuffer dst,
long position)
Delegates to
FileChannel |
long |
size() |
void |
truncate(long size) |
boolean |
truncateIfSmaller(long size)
Only truncate if the size of the file is less than the size argument.
|
int |
write(ByteBuffer src)
Delegates to
FileChannel |
int |
write(ByteBuffer src,
long position)
Delegates to
FileChannel |
getPath, toString
public FileBuffer(String path, String mode)
path
- path to the root of the File
repository.mode
- will be passed to the constructor of RandomAccessFile
FileNotFoundException
public void close() throws IOException
IOException
- if an I/O error occurs.public void flush(boolean includeMetadata) throws IOException
includeMetadata
- flushes also the file metadata, not just the contentIOException
- an I/O error that occurredpublic int read(ByteBuffer dst) throws IOException
FileChannel
IOException
FileChannel.read(ByteBuffer)
public int read(ByteBuffer dst, long position) throws IOException
FileChannel
IOException
FileChannel.read(ByteBuffer, long)
public int write(ByteBuffer src, long position) throws IOException
FileChannel
IOException
FileChannel.write(ByteBuffer, long)
public int write(ByteBuffer src) throws IOException
FileChannel
IOException
FileChannel.write(ByteBuffer)
public long size() throws IOException
IOException
public void truncate(long size) throws IOException
IOException
public boolean truncateIfSmaller(long size) throws IOException
size
- IOException
Version: 5.4.0-ice35-b74
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.