|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.io.InputStream
java.io.ByteArrayInputStream
public class ByteArrayInputStream
ByteArrayInputStream is used for streaming over a byte array.
ByteArrayOutputStream| 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 | |
|---|---|
ByteArrayInputStream(byte[] buf)
Constructs a new ByteArrayInputStream on the byte array buf. |
|
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 | |
|---|---|
int |
available()
Answers a int representing then number of bytes that are available before this ByteArrayInputStream will block. |
void |
close()
Close the ByteArrayInputStream. |
void |
mark(int readlimit)
Set a Mark position in this ByteArrayInputStream. |
boolean |
markSupported()
Answers a boolean indicating whether or not this ByteArrayInputStream supports mark() and reset(). |
int |
read()
Reads a single byte from this ByteArrayInputStream and returns the result as an int. |
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. |
void |
reset()
Reset this ByteArrayInputStream to the last marked location. |
long |
skip(long count)
Skips count number of bytes in this InputStream. |
| Methods inherited from class java.io.InputStream |
|---|
read |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected byte[] buf
byte array containing the bytes to stream over.
protected int pos
protected int mark
offset parameter
within the constructor.
protected int count
buf.
| Constructor Detail |
|---|
public ByteArrayInputStream(byte[] buf)
buf.
buf - the byte array to stream overpublic ByteArrayInputStream(byte[] buf,
int offset,
int length)
buf
with the position set to offset and the number of bytes
available set to offset + length.
buf - the byte array to stream overoffset - the offset in buf to start streaming atlength - the number of bytes available to stream over.| Method Detail |
|---|
public int available()
available in class InputStreampublic void close()
throws IOException
close in interface Closeableclose in class InputStreamIOException - If an error occurs attempting to close this InputStream.public void mark(int readlimit)
readLimit
is ignored. Sending reset() will reposition the stream back to the marked position.
mark in class InputStreamreadlimit - ignored.public boolean markSupported()
true.
markSupported in class InputStreamtrue indicates this stream supports mark/reset, false
otherwise.
read
public int read()
- 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.
- Specified by:
read in class InputStream
- Returns:
- the byte read or -1 if end of stream.
read
public 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. 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.
- Overrides:
read in class InputStream
- Parameters:
b - the byte array in which to store the read bytes.offset - the offset in b to store the read bytes.length - the maximum number of bytes to store in b.
- Returns:
- the number of bytes actually read or -1 if end of stream.
reset
public void reset()
- 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.
- Overrides:
reset in class InputStream
skip
public long skip(long count)
- 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.
- Overrides:
skip in class InputStream
- Parameters:
count - the number of bytes to skip.
- Returns:
- the number of bytes actually skipped.
Overview
Package
Class
Tree
Deprecated
Help
Final
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Licensed Materials - Property of IBM
© Copyright IBM Corp. 2006, 2008 All Rights Reserved.