/** * Create a stream compressor with the default compression level. * * @param bs The ScatterGatherBackingStore to receive output * @return A stream compressor */ public static StreamCompressor create(final ScatterGatherBackingStore bs) { return create(Deflater.DEFAULT_COMPRESSION, bs); }
/** * Create a stream compressor with the default compression level. * * @param os The stream to receive output * @return A stream compressor */ static StreamCompressor create(final OutputStream os) { return create(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true)); }
/** * Creates a new ZIP OutputStream filtering the underlying stream. * @param out the outputstream to zip */ public ZipArchiveOutputStream(final OutputStream out) { this.out = out; this.channel = null; def = new Deflater(level, true); streamCompressor = StreamCompressor.create(out, def); }
/** * Creates a new ZIP OutputStream writing to a SeekableByteChannel. * * <p>{@link * org.apache.commons.compress.utils.SeekableInMemoryByteChannel} * allows you to write to an in-memory archive using random * access.</p> * * @param channel the channel to zip to * @throws IOException on error * @since 1.13 */ public ZipArchiveOutputStream(SeekableByteChannel channel) throws IOException { this.channel = channel; def = new Deflater(level, true); streamCompressor = StreamCompressor.create(channel, def); out = null; }
/** * Creates a new ZIP OutputStream writing to a File. Will use * random access if possible. * @param file the file to zip to * @throws IOException on error */ public ZipArchiveOutputStream(final File file) throws IOException { def = new Deflater(level, true); OutputStream o = null; SeekableByteChannel _channel = null; StreamCompressor _streamCompressor = null; try { _channel = Files.newByteChannel(file.toPath(), EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.TRUNCATE_EXISTING)); // will never get opened properly when an exception is thrown so doesn't need to get closed _streamCompressor = StreamCompressor.create(_channel, def); //NOSONAR } catch (final IOException e) { IOUtils.closeQuietly(_channel); _channel = null; o = new FileOutputStream(file); _streamCompressor = StreamCompressor.create(o, def); } out = o; channel = _channel; streamCompressor = _streamCompressor; }
private ScatterZipOutputStream createDeferred(final ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier) throws IOException { final ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(Deflater.DEFAULT_COMPRESSION, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); }
/** * Create a {@link ScatterZipOutputStream} that is backed by a file * * @param file The file to offload compressed data into. * @param compressionLevel The compression level to use, @see #Deflater * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file, final int compressionLevel) throws FileNotFoundException { final ScatterGatherBackingStore bs = new FileBasedScatterGatherBackingStore(file); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(compressionLevel, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); } }
public static ScatterZipOutputStream createDeferred( ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier ) throws IOException { ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); StreamCompressor sc = StreamCompressor.create( Deflater.DEFAULT_COMPRESSION, bs ); return new ScatterZipOutputStream( bs, sc ); }
/** * Create a stream compressor with the default compression level. * * @param bs The ScatterGatherBackingStore to receive output * @return A stream compressor */ public static StreamCompressor create(final ScatterGatherBackingStore bs) { return create(Deflater.DEFAULT_COMPRESSION, bs); }
/** * Create a stream compressor with the default compression level. * * @param os The stream to receive output * @return A stream compressor */ static StreamCompressor create(final OutputStream os) { return create(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true)); }
/** * Creates a new ZIP OutputStream filtering the underlying stream. * @param out the outputstream to zip */ public ZipArchiveOutputStream(final OutputStream out) { this.out = out; this.channel = null; def = new Deflater(level, true); streamCompressor = StreamCompressor.create(out, def); }
/** * Creates a new ZIP OutputStream writing to a SeekableByteChannel. * * <p>{@link * org.apache.commons.compress.utils.SeekableInMemoryByteChannel} * allows you to write to an in-memory archive using random * access.</p> * * @param channel the channel to zip to * @throws IOException on error * @since 1.13 */ public ZipArchiveOutputStream(SeekableByteChannel channel) throws IOException { this.channel = channel; def = new Deflater(level, true); streamCompressor = StreamCompressor.create(channel, def); out = null; }
private ScatterZipOutputStream createDeferred(final ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier) throws IOException { final ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(Deflater.DEFAULT_COMPRESSION, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); }
/** * Creates a new ZIP OutputStream writing to a File. Will use * random access if possible. * @param file the file to zip to * @throws IOException on error */ public ZipArchiveOutputStream(final File file) throws IOException { def = new Deflater(level, true); OutputStream o = null; SeekableByteChannel _channel = null; StreamCompressor _streamCompressor = null; try { _channel = Files.newByteChannel(file.toPath(), EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.TRUNCATE_EXISTING)); // will never get opened properly when an exception is thrown so doesn't need to get closed _streamCompressor = StreamCompressor.create(_channel, def); //NOSONAR } catch (final IOException e) { IOUtils.closeQuietly(_channel); _channel = null; o = new FileOutputStream(file); _streamCompressor = StreamCompressor.create(o, def); } out = o; channel = _channel; streamCompressor = _streamCompressor; }
/** * Create a {@link ScatterZipOutputStream} that is backed by a file * * @param file The file to offload compressed data into. * @param compressionLevel The compression level to use, @see #Deflater * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file, final int compressionLevel) throws FileNotFoundException { final ScatterGatherBackingStore bs = new FileBasedScatterGatherBackingStore(file); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(compressionLevel, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); } }