DCT Lightfoot v3 API specification

java.io
Class ByteArrayInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.ByteArrayInputStream
All Implemented Interfaces:
Readable

public class ByteArrayInputStream
extends InputStream


Field Summary
protected  byte[] buf
          The buffer
protected  int count
          One greater than the highest index available in the buffer
protected  int mark
          The currently marked position in the stream
protected  int pos
          The position in the buffer
 
Constructor Summary
ByteArrayInputStream(byte[] buf)
          Create a new input stream
ByteArrayInputStream(byte[] buf, int offset, int length)
          Create a new input stream using a range of the buffer
 
Method Summary
 int available()
          How many bytes are available in the buffer without blocking?
 void close()
          Close the stream
 void mark(int readlimit)
          make the stream
 boolean markSupported()
          Is mark supported
 int read()
          read a byte from the stream without blocking
 int read(byte[] buffer, int offset, int length)
          read bytes from the stream without blocking
 void reset()
          reset the buffer to its marked position
 long skip(long n)
          skip a number of bytes in the stream
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf

protected byte[] buf
The buffer


count

protected int count
One greater than the highest index available in the buffer


mark

protected int mark
The currently marked position in the stream


pos

protected int pos
The position in the buffer

Constructor Detail

ByteArrayInputStream

public ByteArrayInputStream(byte[] buf)
Create a new input stream

Parameters:
buf - The buffer to use

ByteArrayInputStream

public ByteArrayInputStream(byte[] buf,
                            int offset,
                            int length)
Create a new input stream using a range of the buffer

Parameters:
buf - The buffer
offset - the offset into the buffer
length - the length of the buffer
Method Detail

available

public int available()
How many bytes are available in the buffer without blocking?

Overrides:
available in class InputStream
Returns:
the number of bytes

close

public void close()
           throws IOException
Close the stream

Overrides:
close in class InputStream
Throws:
IOException - if an IO error occurs

mark

public void mark(int readlimit)
make the stream

Overrides:
mark in class InputStream
Parameters:
readlimit - The number of bytes that can be read while still remembering the mark

markSupported

public boolean markSupported()
Is mark supported

Overrides:
markSupported in class InputStream
Returns:
true if it is

read

public int read()
read a byte from the stream without blocking

Specified by:
read in interface Readable
Specified by:
read in class InputStream
Returns:
a value between 0 and 255 if the stream is available, otherwise -1

read

public int read(byte[] buffer,
                int offset,
                int length)
read bytes from the stream without blocking

Specified by:
read in interface Readable
Overrides:
read in class InputStream
Parameters:
buffer - The buffer to read to
offset - The offset into the buffer to write
length - The length of the buffer
Returns:
the number of bytes read or -1 if there is no more data

reset

public void reset()
reset the buffer to its marked position

Overrides:
reset in class InputStream

skip

public long skip(long n)
          throws IOException
skip a number of bytes in the stream

Specified by:
skip in interface Readable
Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to skip
Returns:
the number of bytes skipped
Throws:
IOException - if the stream is closed

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification