public class WriteBufferDataHandle extends AbstractHigherOrderHandle<Location>
DataHandle and acts as a write buffer.DataHandle.ByteOrderDEFAULT_BLOCK_SIZE, MAX_SEARCH_SIZE| Constructor and Description |
|---|
WriteBufferDataHandle(DataHandle<Location> handle)
Creates a
WriteBufferDataHandle that wraps the given
DataHandle, the default size for the buffer is used
( bytes). |
WriteBufferDataHandle(DataHandle<Location> handle,
int bufferSize)
Creates a
WriteBufferDataHandle that wraps the given
DataHandle |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup()
Clean up data structures after a handle has been closed in the
AbstractHigherOrderHandle.close() method. |
protected void |
ensureOpen() |
boolean |
isReadable()
Gets whether reading from this handle is supported.
|
long |
length()
Returns the length of the data in bytes.
|
long |
offset()
Returns the current offset in the stream.
|
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the stream into an array of
bytes. |
byte |
readByte() |
void |
seek(long pos)
Sets the stream offset, measured from the beginning of the stream, at which
the next read or write occurs.
|
void |
setLength(long length)
Sets the new length of the handle.
|
long |
skip(long n)
Skips over and discards
n bytes of data from the stream. |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
close, exists, getType, handle, isWritableconversionBuffer, getEncoding, getOrder, setEncoding, setOrderget, setsupportsgetInfo, getPriority, setInfo, setPriority, toStringcontext, getContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitavailable, checksum, ensureReadable, ensureWritable, findString, findString, findString, findString, isBigEndian, isLittleEndian, lastModified, read, read, readBoolean, readChar, readCString, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readString, readString, readUnsignedByte, readUnsignedShort, readUTF, setLittleEndian, skipBytes, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLine, writeLong, writeShort, writeUTFget, setgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersionpublic WriteBufferDataHandle(DataHandle<Location> handle)
WriteBufferDataHandle that wraps the given
DataHandle, the default size for the buffer is used
( bytes).handle - the handle to wrappublic WriteBufferDataHandle(DataHandle<Location> handle, int bufferSize)
WriteBufferDataHandle that wraps the given
DataHandlehandle - the handle to wrapbufferSize - the size of the write buffer in bytespublic void write(int b)
throws IOException
IOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
IOExceptionpublic long length()
throws IOException
DataHandlelength in interface DataHandle<Location>length in class AbstractHigherOrderHandle<Location>IOExceptionpublic void setLength(long length)
throws IOException
DataHandlelength - New length.IOException - If there is an error changing the handle's length.public boolean isReadable()
DataHandleisReadable in interface DataHandle<Location>isReadable in class AbstractHigherOrderHandle<Location>protected void ensureOpen()
throws IOException
ensureOpen in class AbstractHigherOrderHandle<Location>IOException - if this handle has been closedpublic long offset()
throws IOException
DataHandleIOExceptionpublic void seek(long pos)
throws IOException
DataHandleIOExceptionpublic long skip(long n)
throws IOException
DataHandlen bytes of data from the stream. The
skip method may, for a variety of reasons, end up skipping over
some smaller number of bytes, possibly 0. This may result from any
of a number of conditions; reaching end of file before n bytes have
been skipped is only one possibility. The actual number of bytes skipped is
returned. If n is negative, no bytes are skipped.n - - the number of bytes to be skipped.IOException - - if an I/O error occurs.public byte readByte()
throws IOException
IOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
DataHandlelen bytes of data from the stream into an array of
bytes.IOExceptionprotected void cleanup()
throws IOException
AbstractHigherOrderHandleAbstractHigherOrderHandle.close() method.cleanup in class AbstractHigherOrderHandle<Location>IOExceptionCopyright © 2015–2022 SciJava. All rights reserved.