Class: java.io.StringBufferInputStream
- public class StringBufferInputStream
- extends InputStream
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.
Inheritance
Superclass tree:- java.lang.Object
- java.io.InputStream
- java.io.StringBufferInputStream
Methods
-
StringBufferInputStreamtop
public StringBufferInputStream(String s)Creates a string input stream to read data from the specified string. -
availabletop
public synchronized int available()Returns the number of bytes that can be read from the input stream without blocking.- Override hierarchy:
- available from InputStream
-
readtop
public synchronized int read()Reads the next byte of data from this input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned.The
readmethod ofStringBufferInputStreamcannot block. It returns the low eight bits of the next character in this input stream's buffer.- Override hierarchy:
- read from InputStream
-
readtop
public synchronized int read(byte[] b, int off, int len)Reads up tolenbytes of data from this input stream into an array of bytes.The
readmethod ofStringBufferInputStreamcannot block. It copies the low eight bits from the characters in this input stream's buffer into the byte array argument.- Override hierarchy:
- read from InputStream
-
resettop
public synchronized void reset()Resets the input stream to begin reading from the first character of this input stream's underlying buffer.- Override hierarchy:
- reset from InputStream
-
skiptop
public synchronized long skip(long n)Skipsnbytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached.- Override hierarchy:
- skip from InputStream
Fields
-
buffer
protected String bufferThe string from which bytes are read. -
count
protected int countThe number of valid characters in the input stream buffer. -
pos
protected int posThe index of the next character to read from the input stream buffer.
