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 = new FileOutputStream(output); CompressorOutputStream cos = new CompressorStreamFactory().createCompressorOutputStream(CompressorStreamFactory.BZIP2, out); IOUtils.copy(new FileInputStream(input), cos); cos.close();
Example (Decompressing a file):
final InputStream is = new FileInputStream(input); CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream(CompressorStreamFactory.BZIP2, is); IOUtils.copy(in, new FileOutputStream(output)); in.close();
@Immutable