Package org.rauschig.jarchivelib
Interface Archiver
-
public interface ArchiverAn Archiver facades a specific archiving library, allowing for simple archiving of files and directories, and extraction of archives.
Some archivers might use an additionalCompressorto compress and decompress their respective archive files.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.Filecreate(java.lang.String archive, java.io.File destination, java.io.File source)Creates an archive from the given source file or directory, and saves it into the given destination.java.io.Filecreate(java.lang.String archive, java.io.File destination, java.io.File... sources)Creates an archive from the given source files or directories, and saves it into the given destination.voidextract(java.io.File archive, java.io.File destination)Extracts the given archive file into the given destination directory.voidextract(java.io.InputStream archive, java.io.File destination)Extracts the given archive supplied as an input stream into the given destination directory.java.lang.StringgetFilenameExtension()Returns the filename extension that indicates the file format this archiver handles.ArchiveStreamstream(java.io.File archive)Reads the given archive file as anArchiveStreamwhich is used to access individualArchiveEntryobjects within the archive without extracting the archive onto the file system.
-
-
-
Method Detail
-
create
java.io.File create(java.lang.String archive, java.io.File destination, java.io.File source) throws java.io.IOExceptionCreates an archive from the given source file or directory, and saves it into the given destination.
If the source is a directory, the archive will contain all the files in that directory, but not the directory itself.
If the archive parameter has no file extension (e.g. "archive" instead of "archive.zip"), the concrete archiver implementation should append it according to its file format (.zip, .tar, .tar.gz, ...).- Parameters:
archive- the name of the archive to createdestination- the destination directory where to place the created archivesource- the input file or directory to archive- Returns:
- the newly created archive file
- Throws:
java.io.IOException- propagated I/O errors byjava.io
-
create
java.io.File create(java.lang.String archive, java.io.File destination, java.io.File... sources) throws java.io.IOExceptionCreates an archive from the given source files or directories, and saves it into the given destination.
If the source is a directory, the archive will contain all the files in that directory, but not the directory itself.
If the archive parameter has no file extension (e.g. "archive" instead of "archive.zip"), the concrete archiver implementation should append it according to its file format (.zip, .tar, .tar.gz, ...).- Parameters:
archive- the name of the archive to createdestination- the destination directory where to place the created archivesources- the input files or directories to archive- Returns:
- the newly created archive file
- Throws:
java.io.IOException- propagated I/O errors byjava.io
-
extract
void extract(java.io.File archive, java.io.File destination) throws java.io.IOExceptionExtracts the given archive file into the given destination directory.
The destination is expected to be a writable directory.- Parameters:
archive- the archive file to extractdestination- the directory to which to extract the files- Throws:
java.io.IOException- propagated I/O errors byjava.io
-
extract
void extract(java.io.InputStream archive, java.io.File destination) throws java.io.IOExceptionExtracts the given archive supplied as an input stream into the given destination directory.
The destination directory is expected to be a writable directory.- Parameters:
archive- the archive contents as a stream.destination- the destination directory.- Throws:
java.io.IOException
-
stream
ArchiveStream stream(java.io.File archive) throws java.io.IOException
Reads the given archive file as anArchiveStreamwhich is used to access individualArchiveEntryobjects within the archive without extracting the archive onto the file system.- Parameters:
archive- the archive file to stream- Returns:
- a new archive stream for the given archive
- Throws:
java.io.IOException- propagated I/O errors byjava.io
-
getFilenameExtension
java.lang.String getFilenameExtension()
Returns the filename extension that indicates the file format this archiver handles. E.g .tar" or ".zip". In case of compressed archives, it will return the composite filename extensions, e.g. ".tar.gz"- Returns:
- a filename extension with a preceding dot
-
-