@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { return readRaw(buffer, offset, length); }
@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
} else { OutputStream out; LZFFileInputStream in = new LZFFileInputStream(src); File resultFile = null; if (toSystemOutput) { out = new FileOutputStream(resultFile); int uncompLen = in.readAndWrite(out); in.close(); out.flush(); out.close();
/** * Fill the uncompressed bytes buffer by reading the underlying inputStream. * @throws IOException */ protected boolean readyBuffer() throws IOException { if (_inputStreamClosed) { throw new IOException("Input stream closed"); } if (_bufferPosition < _bufferLength) { return true; } _bufferLength = _decompressor.decodeChunk(_wrapper, _inputBuffer, _decodedBytes); if (_bufferLength < 0) { close(); return false; } _bufferPosition = 0; return (_bufferPosition < _bufferLength); }
@Override public long skip(long n) throws IOException { return skipRaw(n); } }
} else { OutputStream out; LZFFileInputStream in = new LZFFileInputStream(src); File resultFile = null; if (toSystemOutput) { out = new FileOutputStream(resultFile); int uncompLen = in.readAndWrite(out); in.close(); out.flush(); out.close();
/** * Fill the uncompressed bytes buffer by reading the underlying inputStream. * @throws IOException */ protected boolean readyBuffer() throws IOException { if (_inputStreamClosed) { throw new IOException("Input stream closed"); } if (_bufferPosition < _bufferLength) { return true; } _bufferLength = _decompressor.decodeChunk(_wrapper, _inputBuffer, _decodedBytes); if (_bufferLength < 0) { close(); return false; } _bufferPosition = 0; return (_bufferPosition < _bufferLength); }
@Override public long skip(long n) throws IOException { return skipRaw(n); } }
} else { OutputStream out; LZFFileInputStream in = new LZFFileInputStream(src); File resultFile = null; if (toSystemOutput) { out = new FileOutputStream(resultFile); int uncompLen = in.readAndWrite(out); in.close(); out.flush(); out.close();
@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { return readRaw(buffer, offset, length); }
/** * Fill the uncompressed bytes buffer by reading the underlying inputStream. * @throws IOException */ protected boolean readyBuffer() throws IOException { if (_inputStreamClosed) { throw new IOException("Input stream closed"); } if (_bufferPosition < _bufferLength) { return true; } _bufferLength = _decompressor.decodeChunk(_wrapper, _inputBuffer, _decodedBytes); if (_bufferLength < 0) { close(); return false; } _bufferPosition = 0; return (_bufferPosition < _bufferLength); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public long skip(long n) throws IOException { return skipRaw(n); } }
@Override public int read() throws IOException { if (!readyBuffer()) { return -1; } return _decodedBytes[_bufferPosition++] & 255; }
@Override public int read(byte[] buffer, int offset, int length) throws IOException { return readRaw(buffer, offset, length); }
close(); return skipped;
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * 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; }