java.io
Class StringBufferInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.StringBufferInputStream

public class StringBufferInputStream
extends InputStream

This class implements a String buffer that can be used as an InputStream.


Field Summary
protected  String buffer
          The buffer where data is stored.
protected  int count
          The number of characters to use in the buffer.
protected  int pos
          The position in the buffer.
 
Constructor Summary
StringBufferInputStream(String s)
          Creates an StringBufferInputStream from the specified array of bytes.
 
Method Summary
 int available()
          Returns the number of available bytes in the buffer.
 int read()
          Reads a byte of data.
 int read(byte[] b, int off, int len)
          Reads into an array of bytes.
 void reset()
          Resets the buffer to the beginning.
 long skip(long n)
          Skips n bytes of input.
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected String buffer
The buffer where data is stored.


pos

protected int pos
The position in the buffer.


count

protected int count
The number of characters to use in the buffer.

Constructor Detail

StringBufferInputStream

public StringBufferInputStream(String s)
Creates an StringBufferInputStream from the specified array of bytes.

Parameters:
s - the input buffer (not copied)
Method Detail

read

public int read()
Reads a byte of data.

Specified by:
read in class InputStream
Returns:
the byte read, or -1 if the end of the stream is reached.

read

public int read(byte[] b,
                int off,
                int len)
Reads into an array of bytes.

Overrides:
read in class InputStream
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.

skip

public long skip(long n)
Skips n bytes of input.

Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to be skipped
Returns:
the actual number of bytes skipped.

available

public int available()
Returns the number of available bytes in the buffer.

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

reset

public void reset()
Resets the buffer to the beginning.

Overrides:
reset in class InputStream