It's a shame. We already processed every little byte of the content up to know. We should have enough info to decide whether the file is binary or not. But now we have to call RawText.isBinary() which will read all the bytes again. Ok, it will read from memory and it can stop on the first 0 byte. But isn't there a chance that we incrementally ask RawText about binary/not-binary when we are processing the bytes in write(int b)? Then we could also stop buffering when RawText tells us its binary.