Package net.simplace.core.service
Klasse ZIPHelper
java.lang.Object
net.simplace.core.service.ZIPHelper
All the zip operations are handled.
- Autor:
- Andreas Enders
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic voidAdd a file(s) to the zip file from a collection of files.static voidaddToZIP(Collection<File> aFilesCollection, File aSourceZipFile, File aDestinationZipFile) Add a file(s) to the zip file from a collection of files.static voidcreateZIP(String aFileName, InputStream aInputStream, File aDestinationFile) Creates a zip file out of a InputStream.static voidcreateZIP(Collection<File> aFilesCollection, File aDestinationFile) Creates a zip file out of a collection of files.static FilecreateZIP(Collection<ZipEntry> aZipEntriesColl, File aSourceZipFile, File aDestinationZipFile) Generates a new Zip file out of an existing zip file with specific zip entries only.static voidcreateZIPWithPathEntries(File aDirectory, File aZipFile) Packs the given directory into a new zip file with the given namestatic voidcreateZIPWithPathEntries(Collection<File> aFilesCollection, File aDestinationFile, String aParentStartPath) Creates a zip file out of a collection of files.static voidflattenZipArchive(File aSourceFile, File aDestinationFile) Iterates all ZipEntries in the source file and moves them into a new ZipArchive aDestinationFile.static chargetFileSeparator(File aZipArchive) Parses the Entries of the given Zip archive and looks for the file separator character, if it is a directory.static Collection<? extends ZipEntry> getZIPEntries(File aSourceZipFile) Extracts the entries of the given zip-file.static Collection<ZipEntry> getZIPEntriesHavingPathName(File aSourceZipFile, String aName) Returns the entries of a zip file which contains the given name.static Collection<ZipEntry> getZIPEntriesWithoutPathName(File aSourceZipFile, String aName) Returns the entries of a zip file without the given name.static ZipEntrygetZIPEntry(File aSourceZipFile, String aFileName) Get the entries of a zip filestatic ZipEntrygetZIPEntryExcludingPath(File aSourceZipFile, String aFileName) Returs the zip entry of the given file name with out the path info.static final booleanpackAndDeleteDirContents(File aZipFile, File aDir, String aExtension, long aOlderThanMillis) 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 booleanreadZIPEntry(File aSourceZipFile, File aDestinationFile, String aFileName) This method reads a given file out of a ZipFile and writes it to the destination file.static String[][]readZIPEntry(File aSourceZipFile, String aFileName, String aDivider) This method reads a given file out of a ZipFile and writes it to the destination file.static voidremoveZipEntry(String aFilename, File aSourceZipFile, File aDestinationZipFile) Add a file(s) to the zip file from a collection of files.static voidremoveZipEntry(List<String> aFilenameList, File aSourceZipFile, File aDestinationZipFile) Add a file(s) to the zip file from a collection of files.Unzips a zip file to the given directory and returns a map of unzipped-filesUnzips a zip file to the given directory and returns a map of unzipped-filesUnzips 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-files.static voidunZIPWithPath(File aSourceZipFile, String aDestinationDir) Unzips a zip file to the given directory structure as how the zipentry specifies.
-
Konstruktordetails
-
ZIPHelper
public ZIPHelper()
-
-
Methodendetails
-
createZIPWithPathEntries
Packs the given directory into a new zip file with the given name- Parameter:
aDirectory-aZipFile-- Löst aus:
ZipException
-
createZIPWithPathEntries
public static void createZIPWithPathEntries(Collection<File> aFilesCollection, File aDestinationFile, String aParentStartPath) 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 zip entry.) *- Parameter:
aFilesCollection-aDestinationFile-aParentStartPath-- Löst aus:
ZipException
-
unZIPWithPath
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.- Parameter:
aSourceZipFile-aDestinationDir-- Löst aus:
ZipException
-
packAndDeleteDirContents
public static final boolean packAndDeleteDirContents(File aZipFile, File aDir, String aExtension, long aOlderThanMillis) 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.- Parameter:
aZipFile-aDir-aExtension-aOlderThanMillis-- Gibt zurück:
- success
-
createZIP
public static void createZIP(Collection<File> aFilesCollection, File aDestinationFile) throws ZipException Creates a zip file out of a collection of files.- Parameter:
aFilesCollection-aDestinationFile-- Löst aus:
ZipException
-
createZIP
public static void createZIP(String aFileName, InputStream aInputStream, File aDestinationFile) throws ZipException Creates a zip file out of a InputStream.- Parameter:
aFileName-aInputStream-aDestinationFile-- Löst aus:
ZipException
-
addToZIP
public static void addToZIP(Collection<File> aFilesCollection, File aSourceZipFile, File aDestinationZipFile) throws ZipException Add a file(s) to the zip file from a collection of files.- Parameter:
aFilesCollection-aSourceZipFile-aDestinationZipFile-- Löst aus:
ZipException
-
addToZIP
public static void addToZIP(File aFileToAdd, File aSourceZipFile, File aDestinationZipFile) throws ZipException Add a file(s) to the zip file from a collection of files.- Parameter:
aFileToAdd-aSourceZipFile-aDestinationZipFile-- Löst aus:
ZipException
-
createZIP
public static File createZIP(Collection<ZipEntry> aZipEntriesColl, File aSourceZipFile, File aDestinationZipFile) throws ZipException Generates a new Zip file out of an existing zip file with specific zip entries only.- Parameter:
aZipEntriesColl-aSourceZipFile-aDestinationZipFile-- Gibt zurück:
- a new Zip file
- Löst aus:
ZipException
-
unZIP
Unzips a zip file to the given directory and returns a map of unzipped-files- Parameter:
aSourceZipFile-aDestinationDir-- Gibt zurück:
- a list of unzipped-files
- Löst aus:
ZipException
-
unZIP
public static List<File> unZIP(File aSourceZipFile, String aDestinationDir, boolean aReplacePercentInPath) throws ZipException Unzips a zip file to the given directory and returns a map of unzipped-files- Parameter:
aSourceZipFile-aDestinationDir-aReplacePercentInPath-- Gibt zurück:
- a list of unzipped-files
- Löst aus:
ZipException
-
unZIP
public static List<File> unZIP(File aSourceZipFile, String aSubPath, String aDestinationDir) 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.- Parameter:
aSourceZipFile-aSubPath-aDestinationDir-- Gibt zurück:
- a list of unzipped-files
- Löst aus:
ZipException
-
unZIP
public static List<File> unZIP(File aSourceZipFile, String aSubPath, String aDestinationDir, boolean aReplacePercentInPath) 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.- Parameter:
aSourceZipFile-aSubPath-aDestinationDir-aReplacePercentInPath-- Gibt zurück:
- a list of unzipped-files
- Löst aus:
ZipException
-
getZIPEntries
Extracts the entries of the given zip-file.- Parameter:
aSourceZipFile-- Gibt zurück:
- Collection of the entries of the given zip-file
- Löst aus:
ZipException
-
getZIPEntriesHavingPathName
public static Collection<ZipEntry> getZIPEntriesHavingPathName(File aSourceZipFile, String aName) throws ZipException Returns the entries of a zip file which contains the given name.- Parameter:
aSourceZipFile-aName-- Gibt zurück:
- the entries of a zip file which contains the given name
- Löst aus:
ZipException
-
getZIPEntriesWithoutPathName
public static Collection<ZipEntry> getZIPEntriesWithoutPathName(File aSourceZipFile, String aName) throws ZipException Returns the entries of a zip file without the given name.- Parameter:
aSourceZipFile-aName-- Gibt zurück:
- the entries of a zip file without the given name
- Löst aus:
ZipException
-
getZIPEntry
Get the entries of a zip file- Parameter:
aSourceZipFile-aFileName-- Gibt zurück:
- the entries of a zip file
- Löst aus:
ZipException
-
getZIPEntryExcludingPath
public static ZipEntry getZIPEntryExcludingPath(File aSourceZipFile, String aFileName) throws ZipException Returs the zip entry of the given file name with out the path info.- Parameter:
aSourceZipFile-aFileName-- Gibt zurück:
- the zip entry of the given file name with out the path info
- Löst aus:
ZipException
-
removeZipEntry
public static void removeZipEntry(List<String> aFilenameList, File aSourceZipFile, File aDestinationZipFile) throws ZipException Add a file(s) to the zip file from a collection of files.- Parameter:
aFilenameList-aSourceZipFile-aDestinationZipFile-- Löst aus:
ZipException
-
removeZipEntry
public static void removeZipEntry(String aFilename, File aSourceZipFile, File aDestinationZipFile) throws ZipException Add a file(s) to the zip file from a collection of files.- Parameter:
aFilename-aSourceZipFile-aDestinationZipFile-- Löst aus:
ZipException
-
readZIPEntry
public static boolean readZIPEntry(File aSourceZipFile, File aDestinationFile, String aFileName) throws ZipException, IOException This method reads a given file out of a ZipFile and writes it to the destination file.- Parameter:
aSourceZipFile-aDestinationFile-aFileName-- Gibt zurück:
- success
- Löst aus:
ZipExceptionIOException
-
readZIPEntry
public static String[][] readZIPEntry(File aSourceZipFile, String aFileName, String aDivider) throws ZipException, IOException This method reads a given file out of a ZipFile and writes it to the destination file.- Parameter:
aSourceZipFile-aFileName-aDestinationFile-- Gibt zurück:
- success
- Löst aus:
ZipExceptionIOException
-
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.- Parameter:
aZipArchive-- Gibt zurück:
- file separator
-
flattenZipArchive
Iterates all ZipEntries in the source file and moves them into a new ZipArchive aDestinationFile. Only files are moved. Directories are not moved. Files are written to the new archive without path entries.- Parameter:
aSourceFile-aDestinationFile-- Löst aus:
ZipException
-