assert requiredBytes > 0;
// We rely on the encoder to choose the number of bytes to read but
// it does not have to be actually accurate, it only matters
// performance wise but this is not a performance critical code.
CharsetEncoder encoder = encoding.newEncoder();
int toRead = (int)((float)requiredBytes / encoder.averageBytesPerChar()) + 1;
toRead = Math.max(toRead, requiredBytes);
char[] readChars = new char[toRead];
int readCount = reader.read(readChars);
if (readCount <= 0) {
// readCount should never be zero but if reader returns zero