in src/main/java/org/apache/commons/io/input/UnsynchronizedBufferedReader.java [141:178]
private int fillBuf() throws IOException {
// assert(pos == end);
if (mark == EOF || pos - mark >= markLimit) {
/* mark isn't set or has exceeded its limit. use the whole buffer */
final int result = in.read(buf, 0, buf.length);
if (result > 0) {
mark = -1;
pos = 0;
end = result;
}
return result;
}
if (mark == 0 && markLimit > buf.length) {
/* the only way to make room when mark=0 is by growing the buffer */
int newLength = buf.length * 2;
if (newLength > markLimit) {
newLength = markLimit;
}
final char[] newbuf = new char[newLength];
System.arraycopy(buf, 0, newbuf, 0, buf.length);
buf = newbuf;
} else if (mark > 0) {
/* make room by shifting the buffered data to left mark positions */
System.arraycopy(buf, mark, buf, 0, buf.length - mark);
pos -= mark;
end -= mark;
mark = 0;
}
/* Set the new position and mark position */
final int count = in.read(buf, pos, buf.length - pos);
if (count != EOF) {
end += count;
}
return count;
}