Methods Summary |
---|
public void | close()Close this Reader - resets the internal state to
the initial values.
eof = false;
position = 0;
mark = -1;
|
private int | doEndOfFile()Handle End of File.
eof = true;
if (throwEofException) {
throw new EOFException();
}
return -1;
|
public long | getPosition()Return the current position.
return position;
|
public long | getSize()Return the size this {@link Reader} emulates.
return size;
|
public synchronized void | mark(int readlimit)Mark the current position.
if (!markSupported) {
throw new UnsupportedOperationException("Mark not supported");
}
mark = position;
this.readlimit = readlimit;
|
public boolean | markSupported()Indicates whether mark is supported.
return markSupported;
|
protected int | processChar()Return a character value for the read() method.
This implementation returns zero.
// do nothing - overridable by subclass
return 0;
|
protected void | processChars(char[] chars, int offset, int length)Process the characters for the read(char[], offset, length)
method.
This implementation leaves the character array unchanged.
// do nothing - overridable by subclass
|
public int | read(char[] chars, int offset, int length)Read the specified number characters into an array.
if (eof) {
throw new IOException("Read after end of file");
}
if (position == size) {
return doEndOfFile();
}
position += length;
int returnLength = length;
if (position > size) {
returnLength = length - (int)(position - size);
position = size;
}
processChars(chars, offset, returnLength);
return returnLength;
|
public int | read()Read a character.
if (eof) {
throw new IOException("Read after end of file");
}
if (position == size) {
return doEndOfFile();
}
position++;
return processChar();
|
public int | read(char[] chars)Read some characters into the specified array.
return read(chars, 0, chars.length);
|
public synchronized void | reset()Reset the stream to the point when mark was last called.
if (!markSupported) {
throw new UnsupportedOperationException("Mark not supported");
}
if (mark < 0) {
throw new IOException("No position has been marked");
}
if (position > (mark + readlimit)) {
throw new IOException("Marked position [" + mark +
"] is no longer valid - passed the read limit [" +
readlimit + "]");
}
position = mark;
eof = false;
|
public long | skip(long numberOfChars)Skip a specified number of characters.
if (eof) {
throw new IOException("Skip after end of file");
}
if (position == size) {
return doEndOfFile();
}
position += numberOfChars;
long returnLength = numberOfChars;
if (position > size) {
returnLength = numberOfChars - (position - size);
position = size;
}
return returnLength;
|