Class java.io.ByteArrayInputStream
All Packages Class Hierarchy This Package Previous Next Index
Class java.io.ByteArrayInputStream
java.lang.Object
|
+----java.io.InputStream
|
+----java.io.ByteArrayInputStream
- public class ByteArrayInputStream
- extends InputStream
This class implements a buffer that can be
used as an InputStream.
-
buf
- The buffer where data is stored.
-
count
- The number of characters to use in the buffer.
-
pos
- The current position in the buffer.
-
ByteArrayInputStream(byte[])
- Creates an ByteArrayInputStream from the specified array of bytes.
-
ByteArrayInputStream(byte[], int, int)
- Creates an ByteArrayInputStream from the specified array of bytes.
-
available()
- Returns the number of available bytes in the buffer.
-
read()
- Reads a byte of data.
-
read(byte[], int, int)
- Reads into an array of bytes.
-
reset()
- Resets the buffer to the beginning.
-
skip(long)
- Skips n bytes of input.
buf
protected byte buf[]
- The buffer where data is stored.
pos
protected int pos
- The current position in the buffer.
count
protected int count
- The number of characters to use in the buffer.
ByteArrayInputStream
public ByteArrayInputStream(byte buf[])
- Creates an ByteArrayInputStream from the specified array of bytes.
- Parameters:
- buf - the input buffer (not copied)
ByteArrayInputStream
public ByteArrayInputStream(byte buf[],
int offset,
int length)
- Creates an ByteArrayInputStream from the specified array of bytes.
- Parameters:
- buf - the input buffer (not copied)
- offset - the offset of the first byte to read
- length - the number of bytes to read
read
public synchronized int read()
- Reads a byte of data.
- Returns:
- the byte read, or -1 if the end of the
stream is reached.
- Overrides:
- read in class InputStream
read
public synchronized int read(byte b[],
int off,
int len)
- Reads into an array of bytes.
- Parameters:
- b - the buffer into which the data is read
- off - the start offset of the data
- len - the maximum number of bytes read
- Returns:
- the actual number of bytes read; -1 is
returned when the end of the stream is reached.
- Overrides:
- read in class InputStream
skip
public synchronized long skip(long n)
- Skips n bytes of input.
- Parameters:
- n - the number of bytes to be skipped
- Returns:
- the actual number of bytes skipped.
- Overrides:
- skip in class InputStream
available
public synchronized int available()
- Returns the number of available bytes in the buffer.
- Overrides:
- available in class InputStream
reset
public synchronized void reset()
- Resets the buffer to the beginning.
- Overrides:
- reset in class InputStream
All Packages Class Hierarchy This Package Previous Next Index