Top Description Fields Constructors Methods
java.io

public Class StringBufferInputStream

extends InputStream
Class Inheritance
Annotations
@Deprecated

Deprecated

This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the StringReader class.

This class allows an application to create an input stream in which the bytes read are supplied by the contents of a string. Applications can also read bytes from a byte array by using a ByteArrayInputStream.

Only the low eight bits of each character in the string are used by this class.

Author
Arthur van Hoff
Since
1.0
See Also
java.io.ByteArrayInputStream, java.io.StringReader

Field Summary

Modifier and TypeField and Description
protected String
buffer

The string from which bytes are read.

protected int
count

The number of valid characters in the input stream buffer.

protected int
pos

The index of the next character to read from the input stream buffer.

Constructor Summary

AccessConstructor and Description
public
StringBufferInputStream(String
the underlying input buffer.
s
)

Creates a string input stream to read data from the specified string.

Method Summary

Modifier and TypeMethod and Description
public synchronized int

Returns:

the value of count - pos, which is the number of bytes remaining to be read from the input buffer.
available
()

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read from the input stream without blocking.

public synchronized int

Returns:

the next byte of data, or -1 if the end of the stream is reached.
read
()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from this input stream.

public synchronized int

Returns:

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
read
(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public synchronized void
reset()

Overrides java.io.InputStream.reset.

Resets the input stream to begin reading from the first character of this input stream's underlying buffer.

public synchronized long

Returns:

the actual number of bytes skipped.
skip
(long
the number of bytes to be skipped.
n
)

Overrides java.io.InputStream.skip.

Skips n bytes of input from this input stream.

Inherited from java.io.InputStream:
closemarkmarkSupportednullInputStreamreadreadAllBytesreadNBytesreadNBytesskipNBytestransferTo

Field Detail

bufferback to summary
protected String buffer

The string from which bytes are read.

countback to summary
protected int count

The number of valid characters in the input stream buffer.

See Also
java.io.StringBufferInputStream#buffer
posback to summary
protected int pos

The index of the next character to read from the input stream buffer.

See Also
java.io.StringBufferInputStream#buffer

Constructor Detail

StringBufferInputStreamback to summary
public StringBufferInputStream(String s)

Creates a string input stream to read data from the specified string.

Parameters
s:String

the underlying input buffer.

Method Detail

availableback to summary
public synchronized int available()

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read from the input stream without blocking.

Returns:int

the value of count - pos, which is the number of bytes remaining to be read from the input buffer.

Annotations
@Override
readback to summary
public synchronized int read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

Implementation Specification

The read method of StringBufferInputStream cannot block. It returns the low eight bits of the next character in this input stream's buffer.

Returns:int

Doc from java.io.InputStream.read.

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
readback to summary
public synchronized int read(byte[] b, int off, int len)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

Implementation Specification

The read method of StringBufferInputStream cannot block. It copies the low eight bits from the characters in this input stream's buffer into the byte array argument.

Parameters
b:byte[]

Doc from java.io.InputStream.read.

the buffer into which the data is read.

off:int

Doc from java.io.InputStream.read.

the start offset in array b at which the data is written.

len:int

Doc from java.io.InputStream.read.

the maximum number of bytes to read.

Returns:int

Doc from java.io.InputStream.read.

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
@SuppressWarnings:deprecation
resetback to summary
public synchronized void reset()

Overrides java.io.InputStream.reset.

Resets the input stream to begin reading from the first character of this input stream's underlying buffer.

Annotations
@Override
skipback to summary
public synchronized long skip(long n)

Overrides java.io.InputStream.skip.

Skips n bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached.

Parameters
n:long

Doc from java.io.InputStream.skip.

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Annotations
@Override