@Override public InputStream decompressingStream(InputStream compressedStream) throws IOException { try { return CommonsStreamFactory.createCompressorInputStream(getCompressionType(), compressedStream); } catch (CompressorException e) { throw new IOException(e); } }
@Override public InputStream decompressingStream(InputStream compressedStream) throws IOException { try { return CommonsStreamFactory.createCompressorInputStream(getCompressionType(), compressedStream); } catch (CompressorException e) { throw new IOException(e); } }
@Override public String getFilenameExtension() { return getCompressionType().getDefaultFileExtension(); }
@Override public String getFilenameExtension() { return getCompressionType().getDefaultFileExtension(); }
/** * Uses the {@link CompressorStreamFactory} and the name of the given compressor to create a new * {@link CompressorOutputStream} for the given destination {@link File}. * * @param compressor the invoking compressor * @param destination the file to create the {@link CompressorOutputStream} for * @return a new {@link CompressorOutputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination) throws IOException, CompressorException { return createCompressorOutputStream(compressor.getCompressionType(), destination); }
/** * Uses the {@link CompressorStreamFactory} and the name of the given compressor to create a new * {@link CompressorOutputStream} for the given destination {@link File}. * * @param compressor the invoking compressor * @param destination the file to create the {@link CompressorOutputStream} for * @return a new {@link CompressorOutputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorOutputStream createCompressorOutputStream(CommonsCompressor compressor, File destination) throws IOException, CompressorException { return createCompressorOutputStream(compressor.getCompressionType(), destination); }
@Override public void decompress(File source, File destination) throws IOException { assertSource(source); assertDestination(destination); if (destination.isDirectory()) { destination = new File(destination, getDecompressedFilename(source)); } CompressorInputStream compressed = null; FileOutputStream output = null; try { compressed = createCompressorInputStream(getCompressionType(), source); output = new FileOutputStream(destination); IOUtils.copy(compressed, output); } catch (CompressorException e) { throw new IOException(e); } finally { IOUtils.closeQuietly(compressed); IOUtils.closeQuietly(output); } }
@Override public void decompress(File source, File destination) throws IOException { assertSource(source); assertDestination(destination); if (destination.isDirectory()) { destination = new File(destination, getDecompressedFilename(source)); } CompressorInputStream compressed = null; FileOutputStream output = null; try { compressed = createCompressorInputStream(getCompressionType(), source); output = new FileOutputStream(destination); IOUtils.copy(compressed, output); } catch (CompressorException e) { throw new IOException(e); } finally { IOUtils.closeQuietly(compressed); IOUtils.closeQuietly(output); } }