Package io.github.astrapi69.file.zip
Class ZipExtensions
- java.lang.Object
-
- io.github.astrapi69.file.zip.ZipExtensions
-
public final class ZipExtensions extends java.lang.Object
The classZipExtensions
provides functionality for ziping and unzipping files.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
extractZipEntry(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry target, java.io.File toDirectory)
Extract zip entry.static boolean
isZip(java.lang.String filename)
Checks if the given filename is a zip-file.static void
unzip(java.util.zip.ZipFile zipFile, java.io.File toDir)
Unzip.static void
zip(java.io.File fileToZip, java.io.File zipFile)
Zip the given file.static void
zip(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter)
Zip the given file.static void
zip(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter, boolean createFile)
Zip the given file.static void
zipFiles(java.io.File file, java.io.File dirToZip, java.io.FileFilter... excludeFileFilter)
Zip files.
-
-
-
Method Detail
-
extractZipEntry
public static void extractZipEntry(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry target, java.io.File toDirectory) throws java.io.IOException
Extract zip entry.- Parameters:
zipFile
- the zip filetarget
- the targettoDirectory
- the to directory- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
isZip
public static boolean isZip(java.lang.String filename)
Checks if the given filename is a zip-file.- Parameters:
filename
- The filename to check.- Returns:
- True if the filename is a zip-file otherwise false.
-
unzip
public static void unzip(java.util.zip.ZipFile zipFile, java.io.File toDir) throws java.io.IOException
Unzip.- Parameters:
zipFile
- the zip filetoDir
- the to dir- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
zip
public static void zip(java.io.File fileToZip, java.io.File zipFile) throws java.io.FileNotFoundException, java.io.IOException, FileDoesNotExistException
Zip the given file.- Parameters:
fileToZip
- the file to zip.zipFile
- the zip file- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.FileDoesNotExistException
- the file does not exist exception
-
zip
public static void zip(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter) throws java.io.FileNotFoundException, java.io.IOException, FileDoesNotExistException
Zip the given file.- Parameters:
dirToZip
- the dir to zipzipFile
- the zip filefilter
- the filter- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.FileDoesNotExistException
- the file does not exist exception
-
zip
public static void zip(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter, boolean createFile) throws java.io.FileNotFoundException, java.io.IOException, FileDoesNotExistException
Zip the given file.- Parameters:
dirToZip
- the dir to zipzipFile
- the zip filefilter
- the filtercreateFile
- the create file- Throws:
java.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.FileDoesNotExistException
- the file does not exist exception
-
zipFiles
public static void zipFiles(java.io.File file, java.io.File dirToZip, java.io.FileFilter... excludeFileFilter) throws java.io.IOException
Zip files.- Parameters:
file
- the filedirToZip
- the dir to zipexcludeFileFilter
- the file filter for files to exclude- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
-