Methods Summary |
---|
public synchronized int | available()Returns the number of bytes that can be read from the input
stream without blocking.
return count - pos;
|
public synchronized int | 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.
The read method of
StringBufferInputStream cannot block. It returns the
low eight bits of the next character in this input stream's buffer.
return (pos < count) ? (buffer.charAt(pos++) & 0xFF) : -1;
|
public synchronized int | read(byte[] b, int off, int len)Reads up to len bytes of data from this input stream
into an array of bytes.
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.
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
}
if (pos >= count) {
return -1;
}
if (pos + len > count) {
len = count - pos;
}
if (len <= 0) {
return 0;
}
String s = buffer;
int cnt = len;
while (--cnt >= 0) {
b[off++] = (byte)s.charAt(pos++);
}
return len;
|
public synchronized void | reset()Resets the input stream to begin reading from the first character
of this input stream's underlying buffer.
pos = 0;
|
public synchronized long | skip(long n)Skips n bytes of input from this input stream. Fewer
bytes might be skipped if the end of the input stream is reached.
if (n < 0) {
return 0;
}
if (n > count - pos) {
n = count - pos;
}
pos += n;
return n;
|