@Override public XZCompressorInputStream create(InputStream in) throws IOException { return new XZCompressorInputStream(in, true); }
private static boolean internalIsXZCompressionAvailable() { try { XZCompressorInputStream.matches(null, 0); return true; } catch (final NoClassDefFoundError error) { return false; } }
@Override public int read() throws IOException { try { final int ret = in.read(); count(ret == -1 ? -1 : 1); return ret; } catch (org.tukaani.xz.MemoryLimitException e) { throw new MemoryLimitException(e.getMemoryNeeded(), e.getMemoryLimit(), e); } }
FileInputStream fin = new FileInputStream("archive.tar.xz"); BufferedInputStream in = new BufferedInputStream(fin); FileOutputStream out = new FileOutputStream("archive.tar"); XZCompressorInputStream xzIn = new XZCompressorInputStream(in); final byte[] buffer = new byte[buffersize]; int n = 0; while (-1 != (n = xzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); xzIn.close();
@Override public ByteBuffer decompress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); InputStream bytesIn = new ByteArrayInputStream( data.array(), data.arrayOffset() + data.position(), data.remaining()); InputStream ios = new XZCompressorInputStream(bytesIn); try { IOUtils.copy(ios, baos); } finally { ios.close(); } return ByteBuffer.wrap(baos.toByteArray()); }
private static boolean internalIsXZCompressionAvailable() { try { XZCompressorInputStream.matches(null, 0); return true; } catch (final NoClassDefFoundError error) { return false; } }
@Override public int read(final byte[] buf, final int off, final int len) throws IOException { try { final int ret = in.read(buf, off, len); count(ret); return ret; } catch (org.tukaani.xz.MemoryLimitException e) { //convert to commons-compress MemoryLimtException throw new MemoryLimitException(e.getMemoryNeeded(), e.getMemoryLimit(), e); } }
@Override public ByteBuffer decompress(ByteBuffer data) throws IOException { ByteArrayOutputStream baos = getOutputBuffer(data.remaining()); InputStream bytesIn = new ByteArrayInputStream( data.array(), computeOffset(data), data.remaining()); try (InputStream ios = new XZCompressorInputStream(bytesIn)) { IOUtils.copy(ios, baos); } return ByteBuffer.wrap(baos.toByteArray()); }
@Override public boolean matches(byte[] signature, int signatureLength) { return XZCompressorInputStream.matches(signature, signatureLength); }
@Override public int read(final byte[] buf, final int off, final int len) throws IOException { try { final int ret = in.read(buf, off, len); count(ret); return ret; } catch (org.tukaani.xz.MemoryLimitException e) { //convert to commons-compress MemoryLimtException throw new MemoryLimitException(e.getMemoryNeeded(), e.getMemoryLimit(), e); } }
return new BZip2CompressorInputStream(in, true); } else if (fileName.endsWith(XZ_SUFFIX)) { return new XZCompressorInputStream(in, true); } else if (fileName.endsWith(SNAPPY_SUFFIX)) { return new FramedSnappyCompressorInputStream(in);
@Override public boolean matches(byte[] signature, int signatureLength) { return XZCompressorInputStream.matches(signature, signatureLength); }
@Override public int read() throws IOException { try { final int ret = in.read(); count(ret == -1 ? -1 : 1); return ret; } catch (org.tukaani.xz.MemoryLimitException e) { throw new MemoryLimitException(e.getMemoryNeeded(), e.getMemoryLimit(), e); } }
/** * open a compressed InputStream * @param in the InputStream to decompress * @return the InputStream to read from * @throws IOException if an I/O error occurs */ private InputStream openCompressedStream(InputStream in) throws IOException { if(mCurrentTask.compression==null) return in; switch(mCurrentTask.compression) { default: case none: return in; case gzip: return new GzipCompressorInputStream(in); case bzip: return new BZip2CompressorInputStream(in); case xz: return new XZCompressorInputStream(in); } }
throw new CompressorException("XZ compression is not available." + YOU_NEED_XZ_JAVA); return new XZCompressorInputStream(in, actualDecompressConcatenated, memoryLimitInKb);
public static @Nonnull XZCompressorInputStream getXZInputStream( InputStream in ) throws ArchiverException { try { return new XZCompressorInputStream( in ); } catch ( IOException ioe ) { throw new ArchiverException( "Trouble creating BZIP2 compressor, invalid file ?", ioe ); } }
return new XZCompressorInputStream( istream );
@Override public XZCompressorInputStream create(InputStream in) throws IOException { return new XZCompressorInputStream(in, true); }
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new XZCompressorInputStream(containerInputStream); } }
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new XZCompressorInputStream(containerInputStream); } }