Package net.simplace.core.service
Class TARHelper
java.lang.Object
net.simplace.core.service.TARHelper
All the tar operations are handled.
- Author:
- Andreas Enders
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Add a file(s) to the zip file from a collection of files.static void
addToTar
(Collection<File> aFilesCollection, File aSourceTarFile, File aDestinationTarFile) Add a file(s) to the zip file from a collection of files.static void
createTar
(String aFileName, InputStream aInputStream, File aDestinationFile, boolean doGZIP) Creates a zip file out of a InputStream.static void
createTar
(Collection<File> aFilesCollection, File aDestinationFile, boolean doGZIP) Creates a zip file out of a collection of files.static void
createTARWithPathEntries
(File aDirectory, File aTarFile, boolean doGZIP) Packs the given directory into a new zipfile with the given namestatic void
createTARWithPathEntries
(Collection<File> aFilesCollection, File aDestinationFile, String aParentStartPath, boolean doGZIP) Creates a zip file out of a collection of files.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.static Collection<com.ice.tar.TarEntry>
getTAREntries
(File aSourceTarFile, boolean doUnGZIP) Extracts the entries of the given zip-file.static File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given namestatic 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.static final boolean
packDirContents
(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.static File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given namestatic File
Packs the given directory into a new zipfile with the given nameUnTars a Tar file to the given directory and returns a map of unTarped-filesUnzips a zip file to the given directory and returns a map of unzipped-files.unTar
(File aSourceTarFile, String aSubPath, String aDestinationDir, boolean aReplacePercentInPath, boolean doUnGZIP) Unzips a zip file to the given directory and returns a map of unzipped-files.Unzips a zip file to the given directory and returns a map of unzipped-filesstatic void
unTarWithPath
(File aSourceTarFile, String aDestinationDir, boolean doUnGZIP) Unzips a zip file to the given directory structure as how the zipentry specifies.
-
Method Details
-
gz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
gz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-doDeletSourceFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
gz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-aDestFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
gz
public static File gz(File aSourceFile, File aDestFile, boolean doDeletSourceFile) throws ZipException Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-aDestFile
-doDeletSourceFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
ungz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-aDestFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
ungz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-doDeleteSourceFile
-aDestFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
ungz
Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-aDestFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
ungz
public static File ungz(File aSourceFile, File aDestFile, boolean doDeleteSourceFile) throws ZipException Packs the given directory into a new zipfile with the given name- Parameters:
aSourceFile
-aDestFile
-doDeleteSourceFile
-- Returns:
- a new zipfile with the given name
- Throws:
ZipException
-
createTARWithPathEntries
public static void createTARWithPathEntries(File aDirectory, File aTarFile, boolean doGZIP) throws ZipException Packs the given directory into a new zipfile with the given name- Parameters:
aDirectory
-aTarFile
-doGZIP
-- Throws:
ZipException
-
createTARWithPathEntries
public static void createTARWithPathEntries(Collection<File> 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.) *- Parameters:
aFilesCollection
-aDestinationFile
-aParentStartPath
-doGZIP
-- Throws:
ZipException
-
unTarWithPath
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.- Parameters:
aSourceTarFile
-aDestinationDir
-doUnGZIP
-- Throws:
ZipException
-
packAndDeleteDirContents
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.- Parameters:
aTarFile
-aDir
-aExtension
-aOlderThanMillis
-doGZIP
-- Returns:
- success
-
packDirContents
public static final boolean packDirContents(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.- Parameters:
aTarFile
-aDir
-aExtension
-aOlderThanMillis
-doGZIP
-- Returns:
- success
-
createTar
public static void createTar(Collection<File> aFilesCollection, File aDestinationFile, boolean doGZIP) throws ZipException Creates a zip file out of a collection of files.- Parameters:
aFilesCollection
-aDestinationFile
-doGZIP
-- Throws:
ZipException
-
createTar
public static void createTar(String aFileName, InputStream aInputStream, File aDestinationFile, boolean doGZIP) throws ZipException Creates a zip file out of a InputStream.- Parameters:
aFileName
-aInputStream
-aDestinationFile
-doGZIP
-- Throws:
ZipException
-
addToTar
public static void addToTar(Collection<File> aFilesCollection, File aSourceTarFile, File aDestinationTarFile) throws ZipException Add a file(s) to the zip file from a collection of files.- Parameters:
aFilesCollection
-aSourceTarFile
-aDestinationTarFile
-- Throws:
ZipException
-
addToTar
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.- Parameters:
aFileToAdd
-aSourceZipFile
-aDestinationZipFile
-- Throws:
ZipException
-
unTAR
public static List<File> unTAR(File aSourceTarFile, String aDestinationDir, boolean doUnGZIP) throws ZipException Unzips a zip file to the given directory and returns a map of unzipped-files- Parameters:
aSourceTarFile
-aDestinationDir
-doUnGZIP
-- Returns:
- a list of unzipped-files
- Throws:
ZipException
-
unTar
public static List<File> 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- Parameters:
aSourceTarFile
-aDestinationDir
-aReplacePercentInPath
-doUnGZIP
-- Returns:
- a list of unTarped-files
- Throws:
ZipException
-
unTar
public static List<File> 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.- Parameters:
aSourceTarFile
-aSubPath
-aDestinationDir
-doUnGZIP
-- Returns:
- a list of unzipped-files
- Throws:
ZipException
-
unTar
public static List<File> 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.- Parameters:
aSourceTarFile
-aSubPath
-aDestinationDir
-aReplacePercentInPath
-doUnGZIP
-- Returns:
- a list of unzipped-files
- Throws:
ZipException
-
getTAREntries
public static Collection<com.ice.tar.TarEntry> getTAREntries(File aSourceTarFile, boolean doUnGZIP) throws ZipException Extracts the entries of the given zip-file.- Parameters:
aSourceTarFile
-doUnGZIP
-- Returns:
- the entries of the given zip-file
- Throws:
ZipException
-
getFileSeparator
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.- Parameters:
aZipArchive
-- Returns:
- file separator
-