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 voidclose()Closes the buffer, cleaning up file state.voidflush(boolean includeMetadata)Flush the buffer, writing any pending content to the underlying storage device, optionally also the file's metadata.java.lang.StringgetMode()Retrieves the current file modeintread(java.nio.ByteBuffer dst)Delegates toFileChannelintread(java.nio.ByteBuffer dst, long position)Delegates toFileChannellongsize()voidtruncate(long size)booleantruncateIfSmaller(long size)Only truncate if the size of the file is less than the size argument.intwrite(java.nio.ByteBuffer src)Delegates toFileChannelintwrite(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 theFilerepository.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.IOExceptionCloses 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.IOExceptionFlush 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.IOExceptionDelegates toFileChannel- Throws:
java.io.IOException- See Also:
FileChannel.read(ByteBuffer)
-
read
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOExceptionDelegates toFileChannel- Throws:
java.io.IOException- See Also:
FileChannel.read(ByteBuffer, long)
-
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOExceptionDelegates toFileChannel- Throws:
java.io.IOException- See Also:
FileChannel.write(ByteBuffer, long)
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOExceptionDelegates 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.IOExceptionOnly 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
-
-