java.lang.Object
io.github.astrapi69.zip.ZipExtensions
The class
ZipExtensions
provides functionality for ziping and unzipping files.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
extractZipEntry
(ZipFile zipFile, ZipEntry target, File toDirectory) Extract zip entry.static boolean
Checks if the given filename is a zip-file.static void
Unzip.static void
Zip the given file.static void
zip
(File dirToZip, File zipFile, FilenameFilter filter) Zip the given file.static void
zip
(File dirToZip, File zipFile, FilenameFilter filter, boolean createFile) Zip the given file.static void
zipFiles
(File file, File dirToZip, FileFilter... excludeFileFilter) Zip files.
-
Method Details
-
extractZipEntry
public static void extractZipEntry(ZipFile zipFile, ZipEntry target, File toDirectory) throws IOException Extract zip entry.- Parameters:
zipFile
- the zip filetarget
- the targettoDirectory
- the to directory- Throws:
IOException
- Signals that an I/O exception has occurred.
-
isZip
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
Unzip.- Parameters:
zipFile
- the zip filetoDir
- the to dir- Throws:
IOException
- Signals that an I/O exception has occurred.
-
zip
public static void zip(File fileToZip, File zipFile) throws FileNotFoundException, IOException, io.github.astrapi69.file.exception.FileDoesNotExistException Zip the given file.- Parameters:
fileToZip
- the file to zip.zipFile
- the zip file- Throws:
FileNotFoundException
- is thrown if the given file is not foundIOException
- Signals that an I/O exception has occurred.io.github.astrapi69.file.exception.FileDoesNotExistException
- the file does not exist exception
-
zip
public static void zip(File dirToZip, File zipFile, FilenameFilter filter) throws FileNotFoundException, IOException, io.github.astrapi69.file.exception.FileDoesNotExistException Zip the given file.- Parameters:
dirToZip
- the dir to zipzipFile
- the zip filefilter
- the filter- Throws:
FileNotFoundException
- is thrown if the given file is not foundIOException
- Signals that an I/O exception has occurred.io.github.astrapi69.file.exception.FileDoesNotExistException
- the file does not exist exception
-
zip
public static void zip(File dirToZip, File zipFile, FilenameFilter filter, boolean createFile) throws FileNotFoundException, IOException, io.github.astrapi69.file.exception.FileDoesNotExistException Zip the given file.- Parameters:
dirToZip
- the dir to zipzipFile
- the zip filefilter
- the filtercreateFile
- the create file- Throws:
FileNotFoundException
- is thrown if the given file is not foundIOException
- Signals that an I/O exception has occurred.io.github.astrapi69.file.exception.FileDoesNotExistException
- the file does not exist exception
-
zipFiles
public static void zipFiles(File file, File dirToZip, FileFilter... excludeFileFilter) throws IOException Zip files.- Parameters:
file
- the filedirToZip
- the dir to zipexcludeFileFilter
- the file filter for files to exclude- Throws:
IOException
- Signals that an I/O exception has occurred.
-