public abstract class RandomAccessStream extends Stream
| Modifier and Type | Field and Description |
|---|---|
protected int |
pos
The index of the next position to read or write in the stream
|
static int |
SEEK_CUR
Current position of the file pointer
|
static int |
SEEK_END
End of file
|
static int |
SEEK_SET
Beginning of file
|
skipBuffer| Constructor and Description |
|---|
RandomAccessStream() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
Closes this I/O connection, releasing any associated resources.
|
int |
getPos()
Returns the current offset in this stream.
|
abstract void |
setPos(int pos)
Sets the file pointer for read and write operations to the given position.
|
abstract void |
setPos(int offset,
int origin)
Sets the file pointer for read and write operations to a new position defined by adding offset to a reference
position specified by origin.
|
asInputStream, asOutputStream, asStream, asStream, readBytes, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytes, writeBytes, writeBytesprotected int pos
public static final int SEEK_SET
public static final int SEEK_CUR
public static final int SEEK_END
public int getPos()
throws IOException
IOException - if an I/O error has occurred.public abstract void setPos(int offset,
int origin)
throws IOException
offset - number of bytes to offset from origin.origin - position from where offset is added. It is specified by one of the SEEK_* constants.java.lang.IllegalArgumentException - if origin is not one of the values specified by the SEEK_* constants.IOException - if the new position is negative or if an I/O error occurs.public abstract void setPos(int pos)
throws IOException
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.IOException - if pos is negative or if an I/O error occurs.public abstract void close()
throws IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableIOException - If an I/O error occurs.