Class AdjustableGZIPOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class AdjustableGZIPOutputStream extends GZIPOutputStream
A customizable extension of GZIPOutputStream that allows users to specify the compression level.

AdjustableGZIPOutputStream enhances the functionality of GZIPOutputStream by providing constructors that let users configure the compression level, enabling control over the trade-off between compression speed and compression ratio.

Key Features

Usage Example


 try (OutputStream fileOut = Files.newOutputStream(Paths.get("compressed.gz"));
      AdjustableGZIPOutputStream gzipOut = new AdjustableGZIPOutputStream(fileOut, Deflater.BEST_COMPRESSION)) {
     gzipOut.write("Example data to compress".getBytes(StandardCharsets.UTF_8));
 }
 

Additional Notes

  • If the specified compression level is invalid, a IllegalArgumentException will be thrown.
  • The default compression level is Deflater.DEFAULT_COMPRESSION when not specified.
  • The AdjustableGZIPOutputStream inherits all thread-safety properties of GZIPOutputStream.
Author:
John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
See Also: