@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
/** * Convenience method that will read and uncompress all data available, * and write it using given {@link OutputStream}. This avoids having to * make an intermediate copy of uncompressed data which would be needed * when doing the same manually. * * @param out OutputStream to use for writing content * * @return Number of bytes written (uncompressed) */ public int readAndWrite(OutputStream out) throws IOException { int total = 0; while (readyBuffer()) { int avail = _bufferLength - _bufferPosition; out.write(_decodedBytes, _bufferPosition, avail); _bufferPosition += avail; // to ensure it looks like we consumed it all total += avail; } return total; }
/** * Convenience method that will read and uncompress all data available, * and write it using given {@link OutputStream}. This avoids having to * make an intermediate copy of uncompressed data which would be needed * when doing the same manually. * * @param out OutputStream to use for writing content * * @return Number of bytes written (uncompressed) */ public int readAndWrite(OutputStream out) throws IOException { int total = 0; while (readyBuffer()) { int avail = _bufferLength - _bufferPosition; out.write(_decodedBytes, _bufferPosition, avail); _bufferPosition += avail; // to ensure it looks like we consumed it all total += avail; } return total; }
/** * Convenience method that will read and uncompress all data available, * and write it using given {@link OutputStream}. This avoids having to * make an intermediate copy of uncompressed data which would be needed * when doing the same manually. * * @param out OutputStream to use for writing content * * @return Number of bytes written (uncompressed) */ public int readAndWrite(OutputStream out) throws IOException { int total = 0; while (readyBuffer()) { int avail = _bufferLength - _bufferPosition; out.write(_decodedBytes, _bufferPosition, avail); _bufferPosition += avail; // to ensure it looks like we consumed it all total += avail; } return total; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { if (!readyBuffer()) { return -1; } if (length < 1) { return 0; } // First let's read however much data we happen to have... int chunkLength = Math.min(_bufferLength - _bufferPosition, length); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; if (chunkLength == length || !_cfgFullReads) { return chunkLength; } // Need more data, then int totalRead = chunkLength; do { offset += chunkLength; if (!readyBuffer()) { break; } chunkLength = Math.min(_bufferLength - _bufferPosition, (length - totalRead)); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; totalRead += chunkLength; } while (totalRead < length); return totalRead; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { if (!readyBuffer()) { return -1; } if (length < 1) { return 0; } // First let's read however much data we happen to have... int chunkLength = Math.min(_bufferLength - _bufferPosition, length); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; if (chunkLength == length || !_cfgFullReads) { return chunkLength; } // Need more data, then int totalRead = chunkLength; do { offset += chunkLength; if (!readyBuffer()) { break; } chunkLength = Math.min(_bufferLength - _bufferPosition, (length - totalRead)); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; totalRead += chunkLength; } while (totalRead < length); return totalRead; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { if (!readyBuffer()) { return -1; } if (length < 1) { return 0; } // First let's read however much data we happen to have... int chunkLength = Math.min(_bufferLength - _bufferPosition, length); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; if (chunkLength == length || !_cfgFullReads) { return chunkLength; } // Need more data, then int totalRead = chunkLength; do { offset += chunkLength; if (!readyBuffer()) { break; } chunkLength = Math.min(_bufferLength - _bufferPosition, (length - totalRead)); System.arraycopy(_decodedBytes, _bufferPosition, buffer, offset, chunkLength); _bufferPosition += chunkLength; totalRead += chunkLength; } while (totalRead < length); return totalRead; }