Package com.dtolabs.rundeck.core.utils
Class ZipUtil
- java.lang.Object
-
- com.dtolabs.rundeck.core.utils.ZipUtil
-
public class ZipUtil extends java.lang.ObjectZipUtil provides utility methods for extracting the contents of a zip file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZipUtil.CopyStreamCopierstreamCopier that simply copies the stream without modification.static interfaceZipUtil.GetStreamstatic classZipUtil.PrefixStripperStrips a prefix from inputstatic interfaceZipUtil.renamerInterface for renaming a filestatic interfaceZipUtil.streamCopierInterface for copying a stream from input to output.
-
Constructor Summary
Constructors Constructor Description ZipUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream)static voidextractZip(java.lang.String path, java.io.File dest)Extracts all contents of the file to the destination directorystatic voidextractZip(java.lang.String zipFilePath, java.io.File destDir, java.io.FilenameFilter filter, ZipUtil.renamer rename, ZipUtil.streamCopier copier)Extract the zip file to the destination, optionally only the matching files and renaming the filesstatic voidextractZip(java.lang.String path, java.io.File dest, java.lang.String prefix)Extracts all contents that match a certain prefixstatic voidextractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, ZipUtil.renamer rename, ZipUtil.streamCopier copier)Extract the zip file to the destination, optionally only the matching files and renaming the filesstatic voidextractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, java.lang.String stripPrefix)Extract the zip file to the destination, optionally only the matching files and renaming the filesstatic voidextractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, java.lang.String stripPrefix, ZipUtil.streamCopier copier)Extract the zip file to the destination, optionally only the matching files and renaming the filesstatic voidextractZip(java.util.Enumeration<? extends java.util.zip.ZipEntry> enumeration, ZipUtil.GetStream streamSource, java.io.File dest, java.io.FilenameFilter filter, ZipUtil.renamer rename, ZipUtil.streamCopier copier)Extract the zip file to the destination, optionally only the matching files and renaming the filesstatic voidextractZipFile(java.lang.String path, java.io.File dest, java.lang.String fileName)Extracts a single entry from the zip
-
-
-
Method Detail
-
extractZip
public static void extractZip(java.lang.String path, java.io.File dest) throws java.io.IOExceptionExtracts all contents of the file to the destination directory- Parameters:
path- zip file pathdest- destination directory- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.lang.String path, java.io.File dest, java.lang.String prefix) throws java.io.IOExceptionExtracts all contents that match a certain prefix- Parameters:
path- zip file pathdest- destination directoryprefix- prefix of contents to extract- Throws:
java.io.IOException- on io error
-
extractZipFile
public static void extractZipFile(java.lang.String path, java.io.File dest, java.lang.String fileName) throws java.io.IOExceptionExtracts a single entry from the zip- Parameters:
path- zip file pathdest- destination directoryfileName- specific filepath to extract- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, java.lang.String stripPrefix) throws java.io.IOExceptionExtract the zip file to the destination, optionally only the matching files and renaming the files- Parameters:
path- zip file pathdest- destination directory to contain filesprefix- match files within the zip if they have this prefix path, or null selects all filesstripPrefix- rename files by removing this prefix if they have it, or null doesn't rename files- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, java.lang.String stripPrefix, ZipUtil.streamCopier copier) throws java.io.IOExceptionExtract the zip file to the destination, optionally only the matching files and renaming the files- Parameters:
path- zip file pathdest- destination directory to contain filesprefix- match files within the zip if they have this prefix path, or null selects all filesstripPrefix- rename files by removing this prefix if they have it, or null doesn't rename filescopier- copier- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.lang.String path, java.io.File dest, java.lang.String prefix, ZipUtil.renamer rename, ZipUtil.streamCopier copier) throws java.io.IOExceptionExtract the zip file to the destination, optionally only the matching files and renaming the files- Parameters:
path- zip file pathdest- destination directory to contain filesprefix- match files within the zip if they have this prefix path, or null selects all filesrename- renamer instancecopier- streamCopier instance- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.lang.String zipFilePath, java.io.File destDir, java.io.FilenameFilter filter, ZipUtil.renamer rename, ZipUtil.streamCopier copier) throws java.io.IOExceptionExtract the zip file to the destination, optionally only the matching files and renaming the files- Parameters:
zipFilePath- zip file pathdestDir- destination directory to contain filesfilter- filter to select matching filesrename- renamer to usecopier- streamCopier to use- Throws:
java.io.IOException- on io error
-
extractZip
public static void extractZip(java.util.Enumeration<? extends java.util.zip.ZipEntry> enumeration, ZipUtil.GetStream streamSource, java.io.File dest, java.io.FilenameFilter filter, ZipUtil.renamer rename, ZipUtil.streamCopier copier) throws java.io.IOExceptionExtract the zip file to the destination, optionally only the matching files and renaming the files- Parameters:
enumeration- zip file pathdest- destination directory to contain filesfilter- filter to select matching filesrename- renamer to usecopier- streamCopier to use- Throws:
java.io.IOException- on io error
-
copyStream
public static void copyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException- Throws:
java.io.IOException
-
-