net.simplace.util.service.TARHelper
All the tar operations are handled.
public final class TARHelper {
// Class Methods public static File
gz(File aSourceFile) throws ZipException;
Packs the given directory into a new zipfile with the given name
returns a new zipfile with the given name
public static File
ungz(File aSourceFile) throws ZipException;
Packs the given directory into a new zipfile with the given name
returns a new zipfile with the given name
public static void
createTARWithPathEntries(File aDirectory, File aTarFile,
boolean doGZIP) throws ZipException;
Packs the given directory into a new zipfile with the given name
- aDirectory
- aTarFile
- doGZIP
public static void
createTARWithPathEntries(Collection aFilesCollection,
File aDestinationFile, String aParentStartPath, boolean doGZIP)
throws ZipException;
Creates a zip file out of a collection of files. The zip file created will have the path
information of each file so that when it is unzipped then it is copied into the specific
directory format. The relative path name is also given as parameter.
Also fecilitates with the feature of adding empty directory entries. (i.e if the list of
files contains a directory then it is added as a directory zipentry.) *
- aFilesCollection
- aDestinationFile
- aParentStartPath
- doGZIP
public static void
unTarWithPath(File aSourceTarFile, String aDestinationDir,
boolean doUnGZIP) throws ZipException;
Unzips a zip file to the given directory structure as how the zipentry specifies.
If a directory zip entry exists then a empty directory with the entry name is created.
- aSourceTarFile
- aDestinationDir
- doUnGZIP
public static final boolean
packAndDeleteDirContents(File aTarFile, File
aDir, String aExtension, long aOlderThanMillis, boolean doGZIP);
Deletes all the files in a directory excluding the subdirectories files, if the given file
is a directory but does not delete the directory itself. Before it Zips the given Files to
another place.
- aTarFile
- aDir
- aExtension
- aOlderThanMillis
- doGZIP
returns success
public static void
createTar(Collection aFilesCollection, File
aDestinationFile, boolean doGZIP) throws ZipException;
Creates a zip file out of a collection of files.
- aFilesCollection
- aDestinationFile
- doGZIP
public static void
createTar(String aFileName, InputStream aInputStream,
File aDestinationFile, boolean doGZIP) throws ZipException;
Creates a zip file out of a InputStream.
- aFileName
- aInputStream
- aDestinationFile
- doGZIP
public static void
addToTar(Collection aFilesCollection, File aSourceTarFile,
File aDestinationTarFile) throws ZipException;
Add a file(s) to the zip file from a collection of files.
- aFilesCollection
- aSourceTarFile
- aDestinationTarFile
public static void
addToTar(File aFileToAdd, File aSourceZipFile, File
aDestinationZipFile) throws ZipException;
Add a file(s) to the zip file from a collection of files.
- aFileToAdd
- aSourceZipFile
- aDestinationZipFile
public static List
unTAR(File aSourceTarFile, String aDestinationDir,
boolean doUnGZIP) throws ZipException;
Unzips a zip file to the given directory and returns a map of unzipped-files
- aSourceTarFile
- aDestinationDir
- doUnGZIP
returns a list of unzipped-files
public static List
unTar(File aSourceTarFile, String aDestinationDir,
boolean aReplacePercentInPath, boolean doUnGZIP) throws ZipException;
UnTars a Tar file to the given directory and returns a map of unTarped-files
- aSourceTarFile
- aDestinationDir
- aReplacePercentInPath
- doUnGZIP
returns a list of unTarped-files
public static List
unTar(File aSourceTarFile, String aSubPath, String
aDestinationDir, boolean doUnGZIP) throws ZipException;
Unzips a zip file to the given directory and returns a map of unzipped-files. Will only
unzip files with the given subPath.
- aSourceTarFile
- aSubPath
- aDestinationDir
- doUnGZIP
returns a list of unzipped-files
public static List
unTar(File aSourceTarFile, String aSubPath, String
aDestinationDir, boolean aReplacePercentInPath, boolean doUnGZIP)
throws ZipException;
Unzips a zip file to the given directory and returns a map of unzipped-files. Will only
unzip files with the given subPath.
- aSourceTarFile
- aSubPath
- aDestinationDir
- aReplacePercentInPath
- doUnGZIP
returns a list of unzipped-files
public static Collection
getTAREntries(File aSourceTarFile, boolean doUnGZIP)
throws ZipException;
Extracts the entries of the given zip-file.
returns the entries of the given zip-file
public static char
getFileSeparator(File aZipArchive);
Parses the Entries of the given Zip archive and looks for the file separator character, if
it is a directory. This method is useful as you don't know if the ZipArchive was packed on
a Linux or on a Windows system. Both operating systems use different file separators when
creating a zip archive. if it should be unzipped on the other OS, this might lead to errors.
returns file separator
}