java.io.StringBufferInputStream
This class is deprecated.
Use StringReader
StringBufferInputStream is a class for to allow a String to be used as an
InputStream.
Summary
Fields
protected |
|
|
String |
buffer |
The String containing the data to read. |
protected |
|
|
int |
count |
The total number of characters inside the buffer. |
protected |
|
|
int |
pos |
The current position within the String buffer. |
Public Constructors
Public Methods
|
synchronized |
|
|
|
int |
available() |
|
synchronized |
|
|
|
int |
read(byte[] b, int offset, int length) |
|
synchronized |
|
|
|
int |
read() |
|
synchronized |
|
|
|
void |
reset() |
|
synchronized |
|
|
|
long |
skip(long n) |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Fields
protected
String
buffer
The String containing the data to read.
protected
int
count
The total number of characters inside the buffer.
protected
int
pos
The current position within the String buffer.
Public Constructors
public
StringBufferInputStream(String str)
Constructs a new StringBufferInputStream on the String
str
.
Parameters
str
| the String to read characters from.
|
Public Methods
public
synchronized
int
available()
Returns an int representing then number of characters that are available
to read.
Returns
- the number of characters available.
public
synchronized
int
read(byte[] b, int offset, int length)
Reads at most
length
bytes from this InputStream and
stores them in byte array
b
starting at
offset
. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
Parameters
b
| the byte array in which to store the read bytes. |
offset
| the offset in b to store the read bytes. |
length
| the maximum number of bytes to store in b . |
Returns
- the number of bytes actually read or -1 if end of stream.
public
synchronized
int
read()
Reads a single byte from this InputStream and returns the result as an
int. The low-order byte is returned or -1 of the end of stream was
encountered.
Returns
- the byte read or -1 if end of stream.
public
synchronized
void
reset()
Reset this InputStream to position 0. Reads/Skips will now take place
from this position.
public
synchronized
long
skip(long n)
Skips
count
number of characters in this InputStream.
Subsequent
read()
's will not return these characters
unless
reset()
is used.
Parameters
n
| the number of characters to skip. |
Returns
- the number of characters actually skipped.