@Override public synchronized int read() throws IOException { if (loc >= end) { return -1; } if (singleByteBuffer == null) { singleByteBuffer = ByteBuffer.allocate(1); } else { singleByteBuffer.rewind(); } int read = read(loc, singleByteBuffer); if (read < 0) { return read; } loc++; return singleByteBuffer.get() & 0xff; }
@Override public synchronized int read(final byte[] b, final int off, int len) throws IOException { if (len <= 0) { return 0; } if (len > end-loc) { if (loc >= end) { return -1; } len = (int)(end-loc); } ByteBuffer buf; buf = ByteBuffer.wrap(b, off, len); int ret = read(loc, buf); if (ret > 0) { loc += ret; return ret; } return ret; }
@Override public synchronized int read() throws IOException { if (loc >= end) { return -1; } if (singleByteBuffer == null) { singleByteBuffer = ByteBuffer.allocate(1); } else { singleByteBuffer.rewind(); } int read = read(loc, singleByteBuffer); if (read < 0) { return read; } loc++; return singleByteBuffer.get() & 0xff; }
@Override public synchronized int read(final byte[] b, final int off, int len) throws IOException { if (len <= 0) { return 0; } if (len > end-loc) { if (loc >= end) { return -1; } len = (int)(end-loc); } ByteBuffer buf; buf = ByteBuffer.wrap(b, off, len); int ret = read(loc, buf); if (ret > 0) { loc += ret; return ret; } return ret; }