Methods Summary |
---|
public synchronized int | available()
if (in == null) {
throw new IOException("Stream Closed");
}
if (slack != null) {
return slack.length - begin;
}
if (in.ready()) {
return 1;
} else {
return 0;
}
|
public synchronized void | close()Closes the Stringreader.
if (in != null) {
in.close();
slack = null;
in = null;
}
|
public synchronized void | mark(int limit)Marks the read limit of the StringReader.
try {
in.mark(limit);
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
}
|
public boolean | markSupported()
return false; // would be imprecise
|
public synchronized int | read()Reads from the Reader , returning the same value.
if (in == null) {
throw new IOException("Stream Closed");
}
byte result;
if (slack != null && begin < slack.length) {
result = slack[begin];
if (++begin == slack.length) {
slack = null;
}
} else {
byte[] buf = new byte[1];
if (read(buf, 0, 1) <= 0) {
return -1;
} else {
result = buf[0];
}
}
return result & 0xFF;
|
public synchronized int | read(byte[] b, int off, int len)Reads from the Reader into a byte array
if (in == null) {
throw new IOException("Stream Closed");
}
if (len == 0) {
return 0;
}
while (slack == null) {
char[] buf = new char[len]; // might read too much
int n = in.read(buf);
if (n == -1) {
return -1;
}
if (n > 0) {
slack = new String(buf, 0, n).getBytes(encoding);
begin = 0;
}
}
if (len > slack.length - begin) {
len = slack.length - begin;
}
System.arraycopy(slack, begin, b, off, len);
if ((begin += len) >= slack.length) {
slack = null;
}
return len;
|
public synchronized void | reset()Resets the StringReader.
if (in == null) {
throw new IOException("Stream Closed");
}
slack = null;
in.reset();
|