Class CompressorStreamFactory

  • All Implemented Interfaces:
    CompressorStreamProvider

    public class CompressorStreamFactory
    extends Object
    implements CompressorStreamProvider

    Factory to create Compressor[In|Out]putStreams from names. To add other implementations you should extend CompressorStreamFactory and override the appropriate methods (and call their implementation from super of course).

    Example (Compressing a file):
     final OutputStream out = Files.newOutputStream(output.toPath());
     CompressorOutputStream cos = new CompressorStreamFactory()
             .createCompressorOutputStream(CompressorStreamFactory.BZIP2, out);
     IOUtils.copy(Files.newInputStream(input.toPath()), cos);
     cos.close();
     
    Example (Decompressing a file):
     final InputStream is = Files.newInputStream(input.toPath());
     CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream(CompressorStreamFactory.BZIP2,
             is);
     IOUtils.copy(in, Files.newOutputStream(output.toPath()));
     in.close();
     
    This class is immutable
    provided that the deprecated method setDecompressConcatenated is not used.
    This class is thread-safe
    even if the deprecated method setDecompressConcatenated is used