Package ome.io.nio
Class FileBuffer
- java.lang.Object
-
- ome.io.nio.AbstractBuffer
-
- ome.io.nio.FileBuffer
-
public class FileBuffer extends AbstractBuffer
Raw file buffer which provides I/O operations within the OMERO file repository.- Since:
- OMERO3.0
-
-
Constructor Summary
Constructors Constructor Description FileBuffer(java.lang.String path, java.lang.String mode)
Default constructor allowing to pass in a non-"rw" file mode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.java.lang.String
getMode()
Retrieves the current file modeint
read(java.nio.ByteBuffer dst)
Delegates toFileChannel
int
read(java.nio.ByteBuffer dst, long position)
Delegates toFileChannel
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(java.nio.ByteBuffer src)
Delegates toFileChannel
int
write(java.nio.ByteBuffer src, long position)
Delegates toFileChannel
-
Methods inherited from class ome.io.nio.AbstractBuffer
getPath, toString
-
-
-
-
Constructor Detail
-
FileBuffer
public FileBuffer(java.lang.String path, java.lang.String mode)
Default constructor allowing to pass in a non-"rw" file mode.- Parameters:
path
- path to the root of theFile
repository.mode
- will be passed to the constructor ofRandomAccessFile
- Throws:
java.io.FileNotFoundException
-
-
Method Detail
-
getMode
public java.lang.String getMode()
Retrieves the current file mode- Returns:
- See above
-
close
public void close() throws java.io.IOException
Closes the buffer, cleaning up file state.- Throws:
java.io.IOException
- if an I/O error occurs.
-
flush
public void flush(boolean includeMetadata) throws java.io.IOException
Flush the buffer, writing any pending content to the underlying storage device, optionally also the file's metadata.- Parameters:
includeMetadata
- flushes also the file metadata, not just the content- Throws:
java.io.IOException
- an I/O error that occurred
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
Delegates toFileChannel
- Throws:
java.io.IOException
- See Also:
FileChannel.read(ByteBuffer)
-
read
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
Delegates toFileChannel
- Throws:
java.io.IOException
- See Also:
FileChannel.read(ByteBuffer, long)
-
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
Delegates toFileChannel
- Throws:
java.io.IOException
- See Also:
FileChannel.write(ByteBuffer, long)
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
Delegates toFileChannel
- Throws:
java.io.IOException
- See Also:
FileChannel.write(ByteBuffer)
-
size
public long size() throws java.io.IOException
- Throws:
java.io.IOException
-
truncate
public void truncate(long size) throws java.io.IOException
- Throws:
java.io.IOException
-
truncateIfSmaller
public boolean truncateIfSmaller(long size) throws java.io.IOException
Only truncate if the size of the file is less than the size argument.- Parameters:
size
-- Returns:
- true if truncation was performed.
- Throws:
java.io.IOException
-
-