@Override public XZCompressorInputStream create(InputStream in) throws IOException { return new XZCompressorInputStream(in, true); }
@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()); }
@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()); }
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);
/** * 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); } }
@Override public CompressorInputStream open(File compressedFile) throws IOException { InputStream is = new FileInputStream(compressedFile); try { return new XZCompressorInputStream(is); } catch (IOException ioe) { try { is.close(); } catch (Exception e) {} throw ioe; } }
@Override public CompressorInputStream open(File compressedFile) throws IOException { InputStream is = new FileInputStream(compressedFile); try { return new XZCompressorInputStream(is); } catch (IOException ioe) { try { is.close(); } catch (Exception e) {} throw ioe; } }
/** * Uncompress a XZ data blob into a new byte array. * * @param data compressed data blob * @return uncompressed data * @throws IOException as per java IO contract */ public static byte[] unxz(final byte[] data) throws IOException { final XZCompressorInputStream xzCompressorInputStream = new XZCompressorInputStream(new ByteArrayInputStream(data)); return InputStreamUtils.readFully(xzCompressorInputStream); }
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();
public ByteArrayOutputStream uncompress(int expectedLength) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(expectedLength); CompressorInputStream in = new XZCompressorInputStream(input); IOUtils.copy(in, out); in.close(); out.flush(); out.close(); return out; }
protected ArchiveWrapper archiveStream(File source) throws IOException { FileInputStream fin = new FileInputStream(source); BufferedInputStream in = new BufferedInputStream(fin); XZCompressorInputStream gzIn = new XZCompressorInputStream(in); TarArchiveInputStream tarIn = new TarArchiveInputStream(gzIn); return new TarArchiveWrapper(tarIn); } }
/** * Uncompress a XZ data blob into a new byte array. * * @param data compressed data blob * @return uncompressed data */ public static byte[] unxz(final byte[] data) { try (final XZCompressorInputStream xzCompressorInputStream = new XZCompressorInputStream(new ByteArrayInputStream(data))) { return InputStreamUtils.readFully(xzCompressorInputStream); } catch (final IOException e) { throw new RuntimeIOException(e); } }
protected ArchiveWrapper archiveStream(File source) throws FileNotFoundException, IOException { FileInputStream fin = new FileInputStream(source); BufferedInputStream in = new BufferedInputStream(fin); XZCompressorInputStream gzIn = new XZCompressorInputStream(in); TarArchiveInputStream tarIn = new TarArchiveInputStream(gzIn); return new TarArchiveWrapper(tarIn); } }
List<File> uncompressTarXzFile(File inputFile, File outputDir, Consumer<ProgressEntity> stateCallback) { try (CountingInputStream countingInputStream = new CountingInputStream(new FileInputStream(inputFile)); InputStream inputStream = new XZCompressorInputStream(countingInputStream)) { final long finalSize = FileUtils.sizeOf(inputFile); return uncompress(inputStream, countingInputStream, outputDir, finalSize, stateCallback); } catch (IOException e) { throw new ArchiveException(TAR_ERROR_MESSAGE, e); } }