@@ -398,10 +398,12 @@ } public byte peek() throws IOException { if (pos == count) fill(); + if (pos == count) + return -1; // nothing left in buffer return buf[pos]; } public int readLine(byte[] b) throws IOException { return readLine(b, 0, b.length);