java.lang.AutoCloseable
FileStream
, MemoryStream
public interface Stream
extends java.lang.AutoCloseable
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the stream and release all associated resources.
|
long |
getLength() |
Get the length of the stream in bytes
|
int |
read(byte[] buffer,
int offset,
int length) |
Read from the stream
|
boolean |
seek(long position) |
Set byte position
|
long |
tell() |
Get current byte position
|
void |
write(byte[] buffer,
int offset,
int length) |
Write to the stream
|
long getLength() throws java.io.IOException
java.io.IOException
boolean seek(long position) throws java.io.IOException
position
- The new position of the stream (-1 for EOS)java.io.IOException
long tell() throws java.io.IOException
java.io.IOException
int read(byte[] buffer, int offset, int length) throws java.io.IOException
buffer
- The buffer where the data is writtenoffset
- The starting element in the bufferlength
- The maximum number of bytes to be readjava.io.IOException
void write(byte[] buffer, int offset, int length) throws java.io.IOException
buffer
- The buffer where the data liesoffset
- The starting element in the bufferlength
- The maximum number of bytes to writejava.io.IOException
void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
java.io.IOException