public class TarFileGenerator extends Object
| Constructor and Description |
|---|
TarFileGenerator() |
| Modifier and Type | Method and Description |
|---|---|
void |
generate(SortedMap<String,File> files,
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream outStream)
The method writes the files from the given sorted Mapping to the given output
stream.
|
void |
generateTarFile(File file,
SortedMap<String,File> files,
boolean useGZ)
The easiest way to generate a tar file with the given file name, the given
list of files that will be added to the archive and a flag for creating a
compressed archive.
|
public void generateTarFile(File file, SortedMap<String,File> files, boolean useGZ) throws IOException
The given Map is a sorted mapping from file names (including directories) the
files will have within the archive to real world files. For example, the
given Map could contain the entries ("dir1/file0", "/home/file12"),
("dir1/file1", "/home/dir14/dir9/file99.txt"),
("README.md", "README.md"). The key of the entries will define how
the archive itself will be structured. In the given example, there will be a
"README.md" file as well as a directory "dir1" in the root
directory of the archive. "dir1" will contain two file
"file0" and "file1". The value of the entries defines where
the content of the files is taken from. It can be seen that these files can
be located in completely different locations.
file - the name and path of the tar file that will be written by this
methodfiles - the mapping of internal file names to file paths used to read
the filesuseGZ - if this flag is true, the tar file will be compressed
using gzip.IOException - is thrown if either the tar file can not be written or
one of the files in the given map can not be read.public void generate(SortedMap<String,File> files, org.apache.commons.compress.archivers.tar.TarArchiveOutputStream outStream) throws IOException
The given Map is a sorted mapping from file names (including directories) the
files will have within the archive to real world files. For example, the
given Map could contain the entries ("dir1/file0", "/home/file12"),
("dir1/file1", "/home/dir14/dir9/file99.txt"),
("README.md", "README.md"). The key of the entries will define how
the archive itself will be structured. In the given example, there will be a
"README.md" file as well as a directory "dir1" in the root
directory of the archive. "dir1" will contain two file
"file0" and "file1". The value of the entries defines where
the content of the files is taken from. It can be seen that these files can
be located in completely different locations.
files - the mapping of internal file names to file paths used to
read the filesoutStream - the output stream to which the files will be written.IOException - is thrown if either the tar file can not be written or
one of the files in the given map can not be read.Copyright © 2019–2020. All rights reserved.