| |
|
| java.lang.Object java.io.InputStream java.io.ByteArrayInputStream
Field Summary | |
protected byte[] | buf The byte array containing the bytes to stream over. | protected int | count The total number of bytes initially available in the byte array
buf . | protected int | mark The current mark position. | protected int | pos The current position within the byte array. |
Constructor Summary | |
public | ByteArrayInputStream(byte buf) Constructs a new ByteArrayInputStream on the byte array buf . | public | ByteArrayInputStream(byte buf, int offset, int length) Constructs a new ByteArrayInputStream on the byte array buf
with the position set to offset and the number of bytes
available set to offset + length . |
Method Summary | |
public synchronized int | available() Answers a int representing then number of bytes that are available before
this ByteArrayInputStream will block. | public void | close() Close the ByteArrayInputStream. | public synchronized void | mark(int readlimit) Set a Mark position in this ByteArrayInputStream. | public boolean | markSupported() Answers a boolean indicating whether or not this ByteArrayInputStream
supports mark() and reset(). | public synchronized int | read() Reads a single byte from this ByteArrayInputStream and returns the result
as an int. | public synchronized int | read(byte b, int offset, int length) Reads at most len bytes from this ByteArrayInputStream and
stores them in byte array b starting at offset
off . | public synchronized void | reset() Reset this ByteArrayInputStream to the last marked location. | public synchronized long | skip(long n) Skips count number of bytes in this InputStream.
Subsequent read() 's will not return these bytes unless
reset() is used. |
buf | protected byte[] buf(Code) | | The byte array containing the bytes to stream over.
|
count | protected int count(Code) | | The total number of bytes initially available in the byte array
buf .
|
mark | protected int mark(Code) | | The current mark position. Initially set to 0 or the offset
parameter within the constructor.
|
pos | protected int pos(Code) | | The current position within the byte array.
|
ByteArrayInputStream | public ByteArrayInputStream(byte buf)(Code) | | Constructs a new ByteArrayInputStream on the byte array buf .
Parameters: buf - the byte array to stream over |
ByteArrayInputStream | public ByteArrayInputStream(byte buf, int offset, int length)(Code) | | Constructs a new ByteArrayInputStream on the byte array buf
with the position set to offset and the number of bytes
available set to offset + length .
Parameters: buf - the byte array to stream over Parameters: offset - the offset in buf to start streaming at Parameters: length - the number of bytes available to stream over. |
available | public synchronized int available()(Code) | | Answers a int representing then number of bytes that are available before
this ByteArrayInputStream will block. This method returns the number of
bytes yet to be read from the underlying byte array.
the number of bytes available before blocking. |
close | public void close() throws IOException(Code) | | Close the ByteArrayInputStream. This implementation frees up resources
associated with this stream.
throws: IOException - If an error occurs attempting to close this InputStream. |
mark | public synchronized void mark(int readlimit)(Code) | | Set a Mark position in this ByteArrayInputStream. The parameter
readLimit is ignored. Sending reset() will reposition the
stream back to the marked position.
Parameters: readlimit - ignored. |
markSupported | public boolean markSupported()(Code) | | Answers a boolean indicating whether or not this ByteArrayInputStream
supports mark() and reset(). This implementation answers
true .
true indicates this stream supports mark/reset,false otherwise. |
read | public synchronized int read()(Code) | | Reads a single byte from this ByteArrayInputStream and returns the result
as an int. The low-order byte is returned or -1 of the end of stream was
encountered. This implementation returns the next available byte from the
target byte array.
the byte read or -1 if end of stream. |
read | public synchronized int read(byte b, int offset, int length)(Code) | | Reads at most len bytes from this ByteArrayInputStream and
stores them in byte array b starting at offset
off . Answer the number of bytes actually read or -1 if no
bytes were read and end of stream was encountered. This implementation
reads bytes from the target byte array.
Parameters: b - the byte array in which to store the read bytes. Parameters: offset - the offset in b to store the read bytes. Parameters: length - the maximum number of bytes to store in b . the number of bytes actually read or -1 if end of stream. |
reset | public synchronized void reset()(Code) | | Reset this ByteArrayInputStream to the last marked location. This
implementation resets the position to either the marked position, the
start position supplied in the constructor or 0 if neither
is provided.
|
skip | public synchronized long skip(long n)(Code) | | Skips count number of bytes in this InputStream.
Subsequent read() 's will not return these bytes unless
reset() is used. This implementation skips
count number of bytes in the target stream.
Parameters: n - the number of bytes to skip. the number of bytes actually skipped. |
|
|
|