SerializableReaderpublic class SerializableReader extends Reader implements Serializable
Fields Summary |
---|
static final long | serialVersionUID | private char[] | data | protected char[] | buf | protected int | pos | protected int | mark | protected int | count |
Constructors Summary |
---|
public SerializableReader(Reader reader)
BufferedReader in = new BufferedReader(reader);
String line = in.readLine();
while (line != null)
{
String current = (data == null) ? "" : new String(data);
String newData = current + line;
data = newData.toCharArray();
line = in.readLine();
}
reader.close();
this.buf = this.data;
this.pos = 0;
this.count = this.buf.length;
|
Methods Summary |
---|
public void | close()Close the stream. Once a stream has been closed, further read(),
ready(), mark(), or reset() invocations will throw an IOException.
Closing a previously-closed stream, however, has no effect.
// Do nothing
| public int | read(char[] cbuf, int off, int len)Read characters into a portion of an array. This method will block
until some input is available, an I/O error occurs, or the end of the
stream is reached.
if (cbuf == null)
{
throw new NullPointerException();
}
else if ((off < 0) || (off > cbuf.length) || (len < 0) ||
((off + len) > cbuf.length) || ((off + len) < 0))
{
throw new IndexOutOfBoundsException();
}
if (pos >= count)
{
return -1;
}
if (pos + len > count)
{
len = count - pos;
}
if (len <= 0)
{
return 0;
}
System.arraycopy(buf, pos, cbuf, off, len);
pos += len;
return len;
|
|