@Override public int read() throws IOException { // Each number is one byte. Skip whitespace. if (currentLine == null || !currentLine.hasNext()) { String line = reader.readLine(); if (line == null) { return -1; } currentLine = new StringTokenIterator(line); if (!currentLine.hasNext()) { return -1; } } return Integer.parseInt(currentLine.next()) & 0xff; }
@Override public int read() throws IOException { if (leftOver != -1) { int next = leftOver; leftOver = -1; return next; } // Each number is one byte. Skip whitespace. if (currentLine == null || !currentLine.hasNext()) { String line = reader.readLine(); if (line == null) { return -1; } currentLine = new StringTokenIterator(line); if (!currentLine.hasNext()) { return -1; } } int next = Integer.parseInt(currentLine.next()) & 0xffff; leftOver = next & 0xff; return (next >> 8) & 0xff; }