/** * Uses the {@link CompressorStreamFactory} to create a new {@link CompressorInputStream} for the given source * {@link File}. * * @param source the file to create the {@link CompressorInputStream} for * @return a new {@link CompressorInputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorInputStream createCompressorInputStream(File source) throws IOException, CompressorException { return createCompressorInputStream(new BufferedInputStream(new FileInputStream(source))); }
/** * Uses the {@link CompressorStreamFactory} to create a new {@link CompressorInputStream} for the given source * {@link File}. * * @param source the file to create the {@link CompressorInputStream} for * @return a new {@link CompressorInputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorInputStream createCompressorInputStream(File source) throws IOException, CompressorException { return createCompressorInputStream(new BufferedInputStream(new FileInputStream(source))); }
/** * Uses the {@link CompressorStreamFactory} to create a new {@link CompressorInputStream} for the compression type * and wraps the given source {@link File} with it. * * @param source the file to create the {@link CompressorInputStream} for * @return a new {@link CompressorInputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorInputStream createCompressorInputStream(CompressionType type, File source) throws IOException, CompressorException { return createCompressorInputStream(type, new BufferedInputStream(new FileInputStream(source))); }
/** * Uses the {@link CompressorStreamFactory} to create a new {@link CompressorInputStream} for the compression type * and wraps the given source {@link File} with it. * * @param source the file to create the {@link CompressorInputStream} for * @return a new {@link CompressorInputStream} * @throws IOException if an I/O error occurs * @throws CompressorException if the compressor name is not known */ static CompressorInputStream createCompressorInputStream(CompressionType type, File source) throws IOException, CompressorException { return createCompressorInputStream(type, new BufferedInputStream(new FileInputStream(source))); }
@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 ArchiveStream stream(File archive) throws IOException { try { return new CommonsArchiveStream(createArchiveInputStream(archiver, createCompressorInputStream(archive))); } catch (ArchiveException e) { throw new IOException(e); } catch (CompressorException e) { throw new IOException(e); } }
@Override public ArchiveStream stream(File archive) throws IOException { try { return new CommonsArchiveStream(createArchiveInputStream(archiver, createCompressorInputStream(archive))); } catch (ArchiveException e) { throw new IOException(e); } catch (CompressorException e) { throw new IOException(e); } }
@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); } }