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.

Variable Index

 o buf
The buffer where data is stored.
 o count
The number of characters to use in the buffer.
 o pos
The current position in the buffer.

Constructor Index

 o ByteArrayInputStream(byte[])
Creates an ByteArrayInputStream from the specified array of bytes.
 o ByteArrayInputStream(byte[], int, int)
Creates an ByteArrayInputStream from the specified array of bytes.

Method Index

 o available()
Returns the number of available bytes in the buffer.
 o read()
Reads a byte of data.
 o read(byte[], int, int)
Reads into an array of bytes.
 o reset()
Resets the buffer to the beginning.
 o skip(long)
Skips n bytes of input.

Variables

 o buf
  protected byte buf[]
The buffer where data is stored.
 o pos
  protected int pos
The current position in the buffer.
 o count
  protected int count
The number of characters to use in the buffer.

Constructors

 o ByteArrayInputStream
  public ByteArrayInputStream(byte buf[])
Creates an ByteArrayInputStream from the specified array of bytes.
Parameters:
buf - the input buffer (not copied)
 o 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

Methods

 o 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
 o 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
 o 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
 o available
  public synchronized int available()
Returns the number of available bytes in the buffer.
Overrides:
available in class InputStream
 o 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