Package org.opencastproject.util
Class ZipUtil
java.lang.Object
org.opencastproject.util.ZipUtil
Provides static methods for compressing and extracting zip files using zip64 extensions when necessary.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic voidExtracts a zip file to a directory.static voidExtracts a zip file to a directory.static voidExtracts a zip file to a directory.static voidExtracts a zip file to a directory.static FileCompresses source files into a zip archivestatic FileCompresses source files into a zip archive (no recursive)static FileCompresses source files into a zip archivestatic FileCompresses source files into a zip archivestatic FileCompresses source files into a zip archive
-
Field Details
-
BEST_SPEED
public static final int BEST_SPEED- See Also:
-
BEST_COMPRESSION
public static final int BEST_COMPRESSION- See Also:
-
DEFAULT_COMPRESSION
public static final int DEFAULT_COMPRESSION- See Also:
-
NO_COMPRESSION
public static final int NO_COMPRESSION- See Also:
-
-
Method Details
-
zip
public static File zip(File[] sourceFiles, File destination, boolean recursive, int level) throws IOException Compresses source files into a zip archive- Parameters:
sourceFiles- AFilearray with the files to include in the root of the archivedestination- AFiledescriptor to the location where the zip file should be createdrecursive- Indicate whether or not recursively zipping nested directorieslevel- The zip algorithm compression level. Ranges between 0 (no compression) and 9 (max. compression)- Returns:
- A
Filedescriptor of the zip archive file - Throws:
IOException- If the zip file can not be created, or the input files names can not be correctly parsed
-
unzip
Extracts a zip file to a directory.- Parameters:
zipFile- AStringwith the path to the source zip archivedestination- AStringwith the location where the zip archive will be extracted. If this destination directory does not exist, it will be created.- Throws:
IOException- if the zip file cannot be read, the destination directory cannot be created or the extraction is not successful
-
zip
public static File zip(String[] sourceFiles, String destination, boolean recursive, int level) throws IOException Compresses source files into a zip archive- Parameters:
sourceFiles- AStringarray with the file names to be included in the root of the archivedestination- AStringwith the path name of the resulting zip filerecursive- Indicate whether or not recursively zipping nested directorieslevel- The zip algorithm compression level. Ranges between 0 (no compression) and 9 (max. compression)- Returns:
- A
Filedescriptor of the zip archive file - Throws:
IOException- If the zip file can not be created, or the input files names can not be correctly parsed
-
zip
public static File zip(String[] sourceFiles, File destination, boolean recursive, int level) throws IOException Compresses source files into a zip archive- Parameters:
sourceFiles- AStringarray with the file names to be included in the root of the archivedestination- AFilewith the path name of the resulting zip filerecursive- Indicate whether or not recursively zipping nested directorieslevel- The zip algorithm compression level. Ranges between 0 (no compression) and 9 (max. compression)- Returns:
- A
Filedescriptor of the zip archive file - Throws:
IOException- If the zip file can not be created, or the input files names can not be correctly parsed
-
zip
public static File zip(File[] sourceFiles, String destination, boolean recursive, int level) throws IOException Compresses source files into a zip archive- Parameters:
sourceFiles- AFilearray with the file names to be included in the root of the archivedestination- AStringwith the path name of the resulting zip filerecursive- Indicate whether or not recursively zipping nested directorieslevel- The zip algorithm compression level. Ranges between 0 (no compression) and 9 (max. compression)- Returns:
- A
Filedescriptor of the zip archive file - Throws:
IOException- If the zip file can not be created, or the input files names can not be correctly parsed
-
zip
Compresses source files into a zip archive (no recursive)- Parameters:
sourceFiles- AFilearray with the file names to be included in the root of the archivedestination- AFilewith the path name of the resulting zip filelevel- The zip algorithm compression level. Ranges between 0 (no compression) and 9 (max. compression)- Returns:
- A
Filedescriptor of the zip archive file - Throws:
IOException- If the zip file can not be created, or the input files names can not be correctly parsed
-
unzip
Extracts a zip file to a directory.- Parameters:
zipFile- AStringwith the path to the source zip archivedestination- AStringwith the location where the zip archive will be extracted. If this destination directory does not exist, it will be created.- Throws:
IOException- if the zip file cannot be read, the destination directory cannot be created or the extraction is not successful
-
unzip
Extracts a zip file to a directory.- Parameters:
zipFile- AFilewith the path to the source zip archivedestination- AStringwith the location where the zip archive will be extracted.- Throws:
IOException- if the zip file cannot be read, the destination directory cannot be created or the extraction is not successful
-
unzip
Extracts a zip file to a directory.- Parameters:
zipFile- AStringwith the path to the source zip archivedestination- AFilewith the location where the zip archive will be extracted.- Throws:
IOException- if the zip file cannot be read, the destination directory cannot be created or the extraction is not successful
-