Archiver¶
-
public interface
Archiver
¶ An Archiver is the interface that provide the basic archive operations like:
- Compress operations
- Extract operations
- List operations
Creation Date: 13/11/2006
Author: Twinsen Tsang
Methods¶
compress¶
-
public boolean
compress
(File src, File dest, boolean includeItself)¶ Compress the
src
todest
in the archive form. If thesrc
is a file, then the resulting archive contains only that file. If thesrc
is a directory, then the resulting archive contains all files (recursively) in the src. If the flagincludeItself
is true , then thesrc
will also include in the archive as the root.Parameters: - src – The source of the file(s) to be archive.
- dest – The destination of the arhived file.
- includeItself – the source directory includes in the archive if it is true, vice versa.
Throws: - IOException – if any kind of I/O Erros
Returns: true if the operations run successfully.
compress¶
-
public boolean
compress
(FileSystem src, File dest)¶ Compress the
src
todest
in the archive form.Parameters: - src – The source of the file(s) to be archive.
- dest – The destination of the arhived file.
- includeItself – the source directory includes in the archive if it is true, vice versa.
Throws: - IOException – if any kind of I/O Errors.
Returns: true if the operations run successfully.
extract¶
-
public boolean
extract
(File archive, File dest)¶ Extract the
archive
to thedest
directory.Parameters: - archive – The archive to be extract.
- dest – The destination directory extract to.
Throws: - IOException – Any kind of I/O Errors.
- IllegalArgumentException – If the
dest
is not a directory.
Returns: true if the operations run successfully.
extract¶
-
public boolean
extract
(File archive, FileSystem dest)¶ Extract the
archive
to thedest
directory.Parameters: - archive – The archive to be extract.
- dest – The destination directory extract to.
Throws: - IOException – Any kind of I/O Errors.
Returns: true if the operations run successfully.
guessCompressedSize¶
-
public long
guessCompressedSize
(File src)¶ Guess how big is the compressed file without compressing actually.
Parameters: - src – The source of the file(s) to be archive.
Throws: - NullPointerException – if the
src
is null. - IOException – if one of the file in the folders does not exist in some reason.
guessCompressedSize¶
-
public long
guessCompressedSize
(FileSystem src)¶ Guess how big is the compressed file without compressing actually.
Parameters: - src – The source of the file(s) to be archive.
Throws: - NullPointerException – if the
src
is null. - IOException – if one of the file in the folders does not exist in some reason.
isSupportArchive¶
-
public boolean
isSupportArchive
(File archive)¶ Check whether the
archive
is supported by this type of archiver. The execution time of this method solely depends on how the archiver structure look like. For example, ArchiverZIP return immediately because it checks only with the extension of the archive file, without the actual content.Parameters: - archive – The archive to be tested.
Returns: true if the archiver support this
archive
.