in src/main/java/org/apache/commons/io/input/ReaderInputStream.java [341:368]
private void fillBuffer() throws IOException {
if (endOfInput) {
return;
}
if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) {
encoderIn.compact();
final int position = encoderIn.position();
// We don't use Reader#read(CharBuffer) here because it is more efficient
// to write directly to the underlying char array (the default implementation
// copies data to a temporary char array).
final int c = reader.read(encoderIn.array(), position, encoderIn.remaining());
if (c == EOF) {
endOfInput = true;
} else {
encoderIn.position(position + c);
}
encoderIn.flip();
}
encoderOut.compact();
lastCoderResult = charsetEncoder.encode(encoderIn, encoderOut, endOfInput);
if (endOfInput) {
lastCoderResult = charsetEncoder.flush(encoderOut);
}
if (lastCoderResult.isError()) {
lastCoderResult.throwException();
}
encoderOut.flip();
}