@Override public int read() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos++] & 0xff; }
public int peek() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos] & 0xff; }
@Override public int read() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos++] & 0xff; }
@Override public int read() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos++] & 0xff; }
public int peek() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos] & 0xff; }
@Override public int readUnsignedByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) { throw new EOFException(); } } return buf[pos++] & 0xff; }
public byte readByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) throw new EOFException(); } return buf[pos++]; }
@Override public byte readByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) throw new EOFException(); } return buf[pos++]; }
@Override public int readUnsignedByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) { throw new EOFException(); } } return buf[pos++] & 0xff; }
public int readUnsignedByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) throw new EOFException(); } return buf[pos++] & 0xff; }
@Override public byte readByte() throws IOException { if (pos >= end) { refill(); if (pos >= end) throw new EOFException(); } return buf[pos++]; }
public int skipBytes(int n) throws IOException { if (end-pos >= n) { pos += n; return n; } if (end-pos<0) return -1; int r = end-pos; pos = end; while (r < n) { refill(); if (end-pos <= 0) return r; int toRead = Math.min(end-pos, n-r); r += toRead; pos += toRead; } return r; }
@Override public int skipBytes(int n) throws IOException { if (end-pos >= n) { pos += n; return n; } if (end-pos<0) return -1; int r = end-pos; pos = end; while (r < n) { refill(); if (end-pos <= 0) return r; int toRead = Math.min(end-pos, n-r); r += toRead; pos += toRead; } return r; }
@Override public int skipBytes(int n) throws IOException { if (end-pos >= n) { pos += n; return n; } if (end-pos<0) return -1; int r = end-pos; pos = end; while (r < n) { refill(); if (end-pos <= 0) return r; int toRead = Math.min(end-pos, n-r); r += toRead; pos += toRead; } return r; }
@Override public int read(byte b[], int off, int len) throws IOException { int r=0; // number of bytes read // first read from our buffer; if (end-pos > 0) { r = Math.min(end-pos, len); System.arraycopy(buf, pos, b, off, r); pos += r; } if (r == len) return r; // amount left to read is >= buffer size if (len-r >= buf.length) { int ret = in.read(b, off+r, len-r); if (ret==-1) return r==0 ? -1 : r; r += ret; return r; } refill(); // first read from our buffer; if (end-pos > 0) { int toRead = Math.min(end-pos, len-r); System.arraycopy(buf, pos, b, off+r, toRead); pos += toRead; r += toRead; return r; } return -1; }