public interface StreamHandle<L extends Location> extends DataHandle<L>
DataHandle.ByteOrder
DEFAULT_BLOCK_SIZE, MAX_SEARCH_SIZE
Modifier and Type | Method and Description |
---|---|
default void |
advance(long bytes)
Increments the handle's offset by the given amount.
|
default void |
close() |
default void |
ensureReadable(long count)
Ensures that the handle has sufficient bytes available to read.
|
default boolean |
ensureWritable(long count)
Ensures that the handle has the correct length to be written to, and
extends it as required.
|
InputStream |
in()
Gets an input stream for reading data, positioned at the current offset.
|
default void |
jump(long n) |
OutputStream |
out()
Gets an output stream for writing data, positioned at the current offset.
|
default int |
read()
Reads the next byte of data from the stream.
|
default int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the stream into an array of
bytes. |
default byte |
readByte() |
void |
resetStream()
Resets the stream to its start.
|
default void |
seek(long pos)
Sets the stream offset, measured from the beginning of the stream, at which
the next read or write occurs.
|
void |
setOffset(long offset)
Sets the offset of the handle to the given position.
|
default void |
write(byte[] b,
int off,
int len) |
default void |
write(int v) |
default void |
writeByte(int v) |
available, checksum, conversionBuffer, exists, findString, findString, findString, findString, getEncoding, getOrder, isBigEndian, isLittleEndian, isReadable, isWritable, lastModified, length, offset, read, readBoolean, readChar, readCString, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readString, readString, readUnsignedByte, readUnsignedShort, readUTF, setEncoding, setLength, setLittleEndian, setOrder, skip, skipBytes, write, writeBoolean, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLine, writeLong, writeShort, writeUTF
get, set
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
InputStream in() throws IOException
IOException
OutputStream out() throws IOException
IOException
void setOffset(long offset)
This method is intended to be called only in conjunction with reading from the input stream, or writing to the output stream. Otherwise, the contents may get out of sync.
default void advance(long bytes) throws IOException
This method is intended to be called only in conjunction with reading from the input stream, or writing to the output stream. Otherwise, the contents may get out of sync.
IOException
default void seek(long pos) throws IOException
DataHandle
seek
in interface DataHandle<L extends Location>
IOException
void resetStream() throws IOException
IOException
- If something goes wrong with the resetdefault void jump(long n) throws IOException, EOFException
IOException
EOFException
default void ensureReadable(long count) throws IOException
DataHandle
ensureReadable
in interface DataHandle<L extends Location>
count
- Number of bytes to read.EOFException
- If there are insufficient bytes available.IOException
- If the handle is write-only, or something goes wrong
with the check.DataHandle.available(long)
default boolean ensureWritable(long count) throws IOException
DataHandle
ensureWritable
in interface DataHandle<L extends Location>
count
- Number of bytes to write.true
if the handle's length was sufficient, or
false
if the handle's length required an extension.IOException
- If the handle is read-only, or something goes wrong
with the check, or there is an error changing the handle's
length.default int read() throws IOException
DataHandle
read
in interface DataHandle<L extends Location>
IOException
- - if an I/O error occurs.default byte readByte() throws IOException
readByte
in interface DataInput
IOException
default int read(byte[] b, int off, int len) throws IOException
DataHandle
len
bytes of data from the stream into an array of
bytes.read
in interface DataHandle<L extends Location>
IOException
default void write(int v) throws IOException
write
in interface DataOutput
IOException
default void writeByte(int v) throws IOException
writeByte
in interface DataHandle<L extends Location>
writeByte
in interface DataOutput
IOException
default void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
IOException
default void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
Copyright © 2015–2022 SciJava. All rights reserved.