|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RandomAccessData
A RandomAccessData provides the interface to support the seek
and getPointer
methods on the input data.
Method Summary | |
---|---|
long |
getPointer()
Returns the current offset in this RandomAccessData. |
int |
read()
Reads the next byte of data. |
int |
read(byte[] b)
Reads some number of bytes from the data and stores them into the buffer array b . |
void |
seek(long pos)
Sets the offset, measured from the beginning of this data, at which the next read or write occurs. |
long |
size()
Returns the size of this data. |
Method Detail |
---|
long getPointer() throws java.io.IOException
java.io.IOException
void seek(long pos) throws java.io.IOException
size
.
Setting the offset beyond the size
of the data does not change the data size.
pos
- the offset position, measured in bytes from the beginning of the data,
at which to set the data pointer.
java.io.IOException
long size() throws java.io.IOException
java.io.IOException
int read() throws java.io.IOException
int
in the range 0
to
255
. If no byte is available because the end of the data
has been reached, the value -1
is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
A subclass must provide an implementation of this method.
-1
if the end of the
stream is reached.
java.io.IOException
- if an I/O error occurs.int read(byte[] b) throws java.io.IOException
b
. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, end of file is detected, or an exception is thrown.
If b
is null
, a
NullPointerException
is thrown. If the length of
b
is zero, then no bytes are read and 0
is
returned; otherwise, there is an attempt to read at least one byte. If
no byte is available because the stream is at end of file, the value
-1
is returned; otherwise, at least one byte is read and
stored into b
.
The first byte read is stored into element b[0]
, the
next one into b[1]
, and so on. The number of bytes read is,
at most, equal to the length of b
. Let k be the
number of bytes actually read; these bytes will be stored in elements
b[0]
through b[
k-1]
,
leaving elements b[
k]
through
b[b.length-1]
unaffected.
If the first byte cannot be read for any reason other than end of
data, then an IOException
is thrown.
b
- the buffer into which the data is read.
-1
is there is no more data.
java.io.IOException
- if an I/O error occurs.InputStream.read(byte[], int, int)
|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |