/** * Returns a new ArchiveInputStream for reading archives. Subclasses can override this to return their own custom * implementation. * * @param archive the archive file to stream from * @return a new ArchiveInputStream for the given archive file * @throws IOException propagated IO exceptions */ protected ArchiveInputStream createArchiveInputStream(File archive) throws IOException { try { return CommonsStreamFactory.createArchiveInputStream(archive); } catch (ArchiveException e) { throw new IOException(e); } }
/** * Returns a new ArchiveOutputStream for creating archives. Subclasses can override this to return their own custom * implementation. * * @param archiveFile the archive file to stream to * @return a new ArchiveOutputStream for the given archive file. * @throws IOException propagated IO exceptions */ protected ArchiveOutputStream createArchiveOutputStream(File archiveFile) throws IOException { try { return CommonsStreamFactory.createArchiveOutputStream(this, archiveFile); } catch (ArchiveException e) { throw new IOException(e); } }
/** * 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))); }
@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); } }
/** * 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 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); } }
static CompressorOutputStream createCompressorOutputStream(CompressionType compressionType, File destination) throws IOException, CompressorException { return createCompressorOutputStream(compressionType.getName(), new FileOutputStream(destination)); }
/** * Returns a new ArchiveInputStream for reading archives. Subclasses can override this to return their own custom * implementation. * * @param archive the archive contents to stream from * @return a new ArchiveInputStream for the given archive file * @throws IOException propagated IO exceptions */ protected ArchiveInputStream createArchiveInputStream(InputStream archive) throws IOException { try { return CommonsStreamFactory.createArchiveInputStream(archive); } catch (ArchiveException e) { throw new IOException(e); } }
/** * 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))); }
/** * Returns a new ArchiveOutputStream for creating archives. Subclasses can override this to return their own custom * implementation. * * @param archiveFile the archive file to stream to * @return a new ArchiveOutputStream for the given archive file. * @throws IOException propagated IO exceptions */ protected ArchiveOutputStream createArchiveOutputStream(File archiveFile) throws IOException { try { return CommonsStreamFactory.createArchiveOutputStream(this, archiveFile); } catch (ArchiveException e) { throw new IOException(e); } }
static CompressorOutputStream createCompressorOutputStream(CompressionType compressionType, File destination) throws IOException, CompressorException { return createCompressorOutputStream(compressionType.getName(), new FileOutputStream(destination)); }
/** * Returns a new ArchiveInputStream for reading archives. Subclasses can override this to return their own custom * implementation. * * @param archive the archive file to stream from * @return a new ArchiveInputStream for the given archive file * @throws IOException propagated IO exceptions */ protected ArchiveInputStream createArchiveInputStream(File archive) throws IOException { try { return CommonsStreamFactory.createArchiveInputStream(archive); } catch (ArchiveException e) { throw new IOException(e); } }
/** * 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))); }
static ArchiveOutputStream createArchiveOutputStream(ArchiveFormat format, File archive) throws IOException, ArchiveException { return createArchiveOutputStream(format.getName(), new FileOutputStream(archive)); }
/** * 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 ArchiveStreamFactory} to create a new {@link ArchiveInputStream} for the given archive file. * * @param archive the archive file * @return a new {@link ArchiveInputStream} for the given archive file * @throws IOException propagated IOException when creating the FileInputStream. * @throws ArchiveException if the archiver name is not known */ static ArchiveInputStream createArchiveInputStream(File archive) throws IOException, ArchiveException { return createArchiveInputStream(new BufferedInputStream(new FileInputStream(archive))); }
/** * 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))); }
static ArchiveOutputStream createArchiveOutputStream(ArchiveFormat format, File archive) throws IOException, ArchiveException { return createArchiveOutputStream(format.getName(), new FileOutputStream(archive)); }
@Override public void compress(File source, File destination) throws IllegalArgumentException, IOException { assertSource(source); assertDestination(destination); if (destination.isDirectory()) { destination = new File(destination, getCompressedFilename(source)); } CompressorOutputStream compressed = null; BufferedInputStream input = null; try { input = new BufferedInputStream(new FileInputStream(source)); compressed = createCompressorOutputStream(this, destination); IOUtils.copy(input, compressed); } catch (CompressorException e) { throw new IOException(e); } finally { IOUtils.closeQuietly(compressed); IOUtils.closeQuietly(input); } }
/** * Returns a new ArchiveInputStream for reading archives. Subclasses can override this to return their own custom * implementation. * * @param archive the archive contents to stream from * @return a new ArchiveInputStream for the given archive file * @throws IOException propagated IO exceptions */ protected ArchiveInputStream createArchiveInputStream(InputStream archive) throws IOException { try { return CommonsStreamFactory.createArchiveInputStream(archive); } catch (ArchiveException e) { throw new IOException(e); } }