@Override public int read() throws IOException { dieIfClosed(); if (atEOD()) { return EOF; } byte[] b = new byte[1]; int result = read(b, 0, 1); if(result >= 0) { if(b[0] < 0) { return b[0]+256; } return b[0]; } return result; }
@Override public int read(byte[] b, int off, int len) throws IOException { dieIfClosed(); if (b == null) { throw new IllegalArgumentException("buffer must not be null"); } if (off < 0 || len < 0 || b.length < off + len) { throw new IndexOutOfBoundsException("can't read past buffer boundaries"); } if (len == 0) { return 0; } if (atEOD()) { return EOF; } int limit = Math.min(remainingBytes(), len); readFully(b, off, limit); return limit; }
@Override public int read(byte[] b, int off, int len) throws IOException { dieIfClosed(); if (b == null) { throw new IllegalArgumentException("buffer must not be null"); } if (off < 0 || len < 0 || b.length < off + len) { throw new IndexOutOfBoundsException("can't read past buffer boundaries"); } if (len == 0) { return 0; } if (atEOD()) { return EOF; } int limit = Math.min(remainingBytes(), len); readFully(b, off, limit); return limit; }
@Override public int read() throws IOException { dieIfClosed(); if (atEOD()) { return EOF; } byte[] b = new byte[1]; int result = read(b, 0, 1); if(result >= 0) { if(b[0] < 0) { return b[0]+256; } return b[0]; } return result; }