com.dtolabs.rundeck.core.utils
Class ZipUtil

java.lang.Object
  extended by com.dtolabs.rundeck.core.utils.ZipUtil

public class ZipUtil
extends java.lang.Object

ZipUtil provides utility methods for extracting the contents of a zip file.


Nested Class Summary
static class ZipUtil.CopyStreamCopier
          streamCopier that simply copies the stream without modification.
static class ZipUtil.PrefixStripper
          Strips a prefix from input
static interface ZipUtil.renamer
          Interface for renaming a file
static interface ZipUtil.streamCopier
          Interface for copying a stream from input to output.
 
Constructor Summary
ZipUtil()
           
 
Method Summary
static void copyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream)
           
static void extractZip(java.lang.String path, java.io.File dest)
          Extracts all contents of the file to the destination directory
static void extractZip(java.lang.String path, 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 files
static void extractZip(java.lang.String path, java.io.File dest, java.lang.String prefix)
          Extracts all contents that match a certain prefix
static void extractZip(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 files
static void extractZip(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 files
static void extractZip(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 files
static void extractZipFile(java.lang.String path, java.io.File dest, java.lang.String fileName)
          Extracts a single entry from the zip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipUtil

public ZipUtil()
Method Detail

extractZip

public static void extractZip(java.lang.String path,
                              java.io.File dest)
                       throws java.io.IOException
Extracts all contents of the file to the destination directory

Parameters:
path - zip file path
dest - destination directory
Throws:
java.io.IOException

extractZip

public static void extractZip(java.lang.String path,
                              java.io.File dest,
                              java.lang.String prefix)
                       throws java.io.IOException
Extracts all contents that match a certain prefix

Parameters:
path - zip file path
dest - destination directory
prefix - prefix of contents to extract
Throws:
java.io.IOException

extractZipFile

public static void extractZipFile(java.lang.String path,
                                  java.io.File dest,
                                  java.lang.String fileName)
                           throws java.io.IOException
Extracts a single entry from the zip

Parameters:
path - zip file path
dest - destination directory
fileName - specific filepath to extract
Throws:
java.io.IOException

extractZip

public static void extractZip(java.lang.String path,
                              java.io.File dest,
                              java.lang.String prefix,
                              java.lang.String stripPrefix)
                       throws java.io.IOException
Extract the zip file to the destination, optionally only the matching files and renaming the files

Parameters:
path - zip file path
dest - destination directory to contain files
prefix - match files within the zip if they have this prefix path, or null selects all files
stripPrefix - rename files by removing this prefix if they have it, or null doesn't rename files
Throws:
java.io.IOException

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.IOException
Extract the zip file to the destination, optionally only the matching files and renaming the files

Parameters:
path - zip file path
dest - destination directory to contain files
prefix - match files within the zip if they have this prefix path, or null selects all files
stripPrefix - rename files by removing this prefix if they have it, or null doesn't rename files
Throws:
java.io.IOException

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.IOException
Extract the zip file to the destination, optionally only the matching files and renaming the files

Parameters:
path - zip file path
dest - destination directory to contain files
prefix - match files within the zip if they have this prefix path, or null selects all files
rename - renamer instance
copier - streamCopier instance
Throws:
java.io.IOException

extractZip

public static void extractZip(java.lang.String path,
                              java.io.File dest,
                              java.io.FilenameFilter filter,
                              ZipUtil.renamer rename,
                              ZipUtil.streamCopier copier)
                       throws java.io.IOException
Extract the zip file to the destination, optionally only the matching files and renaming the files

Parameters:
path - zip file path
dest - destination directory to contain files
filter - filter to select matching files
rename - renamer to use
copier - streamCopier to use
Throws:
java.io.IOException

copyStream

public static void copyStream(java.io.InputStream inputStream,
                              java.io.OutputStream outputStream)
                       throws java.io.IOException
Throws:
java.io.IOException