Package org.sonar.api.utils
Class ZipUtils
- java.lang.Object
-
- org.sonar.api.utils.ZipUtils
-
public final class ZipUtils extends java.lang.ObjectUtility to zip directories and unzip files.- Since:
- 1.10
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.Fileunzip(java.io.File zip, java.io.File toDir)Unzip a file into a directory.static java.io.Fileunzip(java.io.File zip, java.io.File toDir, java.util.function.Predicate<java.util.zip.ZipEntry> filter)Unzip a file to a directory.static java.io.Fileunzip(java.io.InputStream zip, java.io.File toDir)Unzip a file input stream to a directory.static java.io.Fileunzip(java.io.InputStream zip, java.io.File toDir, long unzipSizeThreshold)Unzip a file input stream to a directory.static java.io.Fileunzip(java.io.InputStream stream, java.io.File toDir, java.lang.Long unzipSizeThreshold, java.util.function.Predicate<java.util.zip.ZipEntry> filter)Unzip a file to a directory.static java.io.Fileunzip(java.io.InputStream stream, java.io.File toDir, java.util.function.Predicate<java.util.zip.ZipEntry> filter)Unzip a file to a directory.static voidzipDir(java.io.File dir, java.io.File zip)
-
-
-
Method Detail
-
unzip
public static java.io.File unzip(java.io.File zip, java.io.File toDir) throws java.io.IOExceptionUnzip a file into a directory. The directory is created if it does not exist.- Returns:
- the target directory
- Throws:
java.io.IOException
-
unzip
public static java.io.File unzip(java.io.InputStream zip, java.io.File toDir) throws java.io.IOExceptionUnzip a file input stream to a directory.- Parameters:
zip- the zip file input streamtoDir- the target directory. It is created if needed.- Returns:
- the parameter
toDir - Throws:
java.io.IOException- Since:
- 6.2
-
unzip
public static java.io.File unzip(java.io.InputStream zip, java.io.File toDir, long unzipSizeThreshold) throws java.io.IOExceptionUnzip a file input stream to a directory.- Parameters:
zip- the zip file input streamtoDir- the target directory. It is created if needed.unzipSizeThreshold- The parameter to prevent unzip size to exceed threshold(in Bytes)- Returns:
- the parameter
toDir - Throws:
java.io.IOException- Since:
- 9.10
-
unzip
public static java.io.File unzip(java.io.InputStream stream, java.io.File toDir, java.util.function.Predicate<java.util.zip.ZipEntry> filter) throws java.io.IOExceptionUnzip a file to a directory.- Parameters:
stream- the zip input filetoDir- the target directory. It is created if needed.filter- filter zip entries so that only a subset of directories/files can be extracted to target directory.- Returns:
- the parameter
toDir - Throws:
java.io.IOException- Since:
- 6.2
-
unzip
public static java.io.File unzip(java.io.InputStream stream, java.io.File toDir, @Nullable java.lang.Long unzipSizeThreshold, java.util.function.Predicate<java.util.zip.ZipEntry> filter) throws java.io.IOExceptionUnzip a file to a directory.- Parameters:
stream- the zip input filetoDir- the target directory. It is created if needed.unzipSizeThreshold- optional parameter to prevent unzip size to exceed threshold(in Bytes)filter- filter zip entries so that only a subset of directories/files can be extracted to target directory.- Returns:
- the parameter
toDir - Throws:
java.io.IOException- Since:
- 9.10
-
unzip
public static java.io.File unzip(java.io.File zip, java.io.File toDir, java.util.function.Predicate<java.util.zip.ZipEntry> filter) throws java.io.IOExceptionUnzip a file to a directory.- Parameters:
zip- the zip file. It must exist.toDir- the target directory. It is created if needed.filter- filter zip entries so that only a subset of directories/files can be extracted to target directory.- Returns:
- the parameter
toDir - Throws:
java.io.IOException- Since:
- 6.2
-
zipDir
public static void zipDir(java.io.File dir, java.io.File zip) throws java.io.IOException- Throws:
java.io.IOException
-
-