/** * Create an compressor output stream from an compressor name and an input stream. * * @param name the compressor name, i.e. "gz", "bzip2", "xz", or "pack200" * @param outputStream the output stream * @return the compressor output stream * @throws CompressorException if the archiver name is not known * @throws IllegalArgumentException if the archiver name or stream is null */ @Override public CompressorOutputStream createCompressorOutputStream( final String name, final OutputStream outputStream) throws CompressorException { checkNotNull(outputStream, "outputStream"); checkNotNull(name, "fileName"); try { if (GZIP.equalsIgnoreCase(name)) { return createGZipCompressorOutputStream(outputStream); } else if (BZIP2.equalsIgnoreCase(name)) { return createBZip2CompressorOutputStream(outputStream); } else if (XZ.equalsIgnoreCase(name)) { return createXZCompressorOutputStream(outputStream); } else if (PACK200.equalsIgnoreCase(name)) { return createPack200CompressorOutputStream(outputStream); } else if (nameDetectionFallback && transparentSignatureDetection) { return createForwardingCompressorOutputStream(outputStream); } } catch (IOException e) { throw new CompressorException("Could not create CompressorOutputStream", e); } throw new CompressorException("Compressor: " + name + " not found."); }
@Override public CompressorInputStream createCompressorInputStream( final String fileName, final InputStream inputStream) throws CompressorException { checkNotNull(inputStream, "inputStream"); checkNotNull(fileName, "fileName"); try { if (GZIP.equalsIgnoreCase(fileName)) { return createGZipCompressorInputStream(inputStream); } else if (BZIP2.equalsIgnoreCase(fileName)) { return createBZip2CompressorInputStream(inputStream); } else if (XZ.equalsIgnoreCase(fileName)) { return createXZCompressorInputStream(inputStream); } else if (PACK200.equalsIgnoreCase(fileName)) { return createPack200CompressorInputStream(inputStream); } else if (nameDetectionFallback) { return createCompressorInputStream(inputStream); } } catch (IOException e) { throw new CompressorException("Could not create CompressorInputStream.", e); } throw new CompressorException("Compressor: " + fileName + " not found."); }