ArchiverTar¶
-
public class
ArchiverTar
extends ArchiverNULL¶ Author: Patrick Yip
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. Thesrc
file sets will be archived to TAR format which is comes from Apache Ant Tools Tar. For more details, read Apache Ant Tool TarParameters: - 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.
See also:
hk.hku.cecid.edi.sfrm.archive.Archiver.compress(File,File,boolean)
compress¶
-
public boolean
compress
(FileSystem src, File dest)¶
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. The algorithm of guessing the tar size as follow: For each of file Each header size is TAR_ENTRY_SIZE bytes, and for the data content block. It use TAR_ENTRY_SIZE as a block of data. If for last block of data is not TAR_ENTRY_SIZE, then the rest will padding with the empty bytes. Such that the final guessed size is ceil((file_length/TAR_ENTRY_SIZE)+1)*TAR_ENTRY_SIZE. More details of tar file format can found from this.
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.
Returns: guessed file size in byte
guessCompressedSize¶
-
public long
guessCompressedSize
(FileSystem src)¶