com.evanmclean.evlib.util.zip
Class Unzipper

java.lang.Object
  extended by com.evanmclean.evlib.util.zip.Unzipper

public class Unzipper
extends Object

Unzips an entire zip file into a specified base folder, creating sub-folders as needed.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Nested Class Summary
static class Unzipper.FolderAction
          How to handle folder entries in the zip file (sub-folders are always created for files as needed).
 
Constructor Summary
Unzipper()
          Create unzipper with the default Unzipper.FolderAction of Unzipper.FolderAction.CREATE.
Unzipper(Unzipper.FolderAction folder_action)
          Create unzipper with the specified Unzipper.FolderAction.
 
Method Summary
 Unzipper.FolderAction getFolderAction()
          Get the current Unzipper.FolderAction.
static void run(File zip_file, File base_folder, Unzipper.FolderAction folder_action)
          Unzip the specified zip file.
static void run(InputStream in, File base_folder, Unzipper.FolderAction folder_action)
          Unzip the specified input stream.
static void run(ZipInputStream in, File base_folder, Unzipper.FolderAction folder_action)
          Unzip the specified zip input stream.
 void setFolderAction(Unzipper.FolderAction folder_action)
          Set the Unzipper.FolderAction to use with the next unzip call.
 void unzip(File zip_file, File base_folder)
          Unzip the specified zip file.
 void unzip(InputStream in, File base_folder)
          Unzip the specified input stream.
 void unzip(ZipInputStream in, File base_folder)
          Unzip the specified zip input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Unzipper

public Unzipper()
Create unzipper with the default Unzipper.FolderAction of Unzipper.FolderAction.CREATE.


Unzipper

public Unzipper(Unzipper.FolderAction folder_action)
Create unzipper with the specified Unzipper.FolderAction.

Parameters:
folder_action - See Unzipper.FolderAction.
Method Detail

run

public static void run(File zip_file,
                       File base_folder,
                       Unzipper.FolderAction folder_action)
                throws IOException
Unzip the specified zip file.

Parameters:
zip_file - The zip file to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
folder_action - See Unzipper.FolderAction.
Throws:
IOException

run

public static void run(InputStream in,
                       File base_folder,
                       Unzipper.FolderAction folder_action)
                throws IOException
Unzip the specified input stream.

Parameters:
in - The input stream to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
folder_action - See Unzipper.FolderAction.
Throws:
IOException

run

public static void run(ZipInputStream in,
                       File base_folder,
                       Unzipper.FolderAction folder_action)
                throws IOException
Unzip the specified zip input stream.

Parameters:
in - The zip input stream to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
folder_action - See Unzipper.FolderAction.
Throws:
IOException

getFolderAction

public Unzipper.FolderAction getFolderAction()
Get the current Unzipper.FolderAction.

Returns:
The current Unzipper.FolderAction.

setFolderAction

public void setFolderAction(Unzipper.FolderAction folder_action)
Set the Unzipper.FolderAction to use with the next unzip call.

Parameters:
folder_action - See Unzipper.FolderAction.

unzip

public void unzip(File zip_file,
                  File base_folder)
           throws IOException
Unzip the specified zip file.

Parameters:
zip_file - The zip file to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
Throws:
IOException

unzip

public void unzip(InputStream in,
                  File base_folder)
           throws IOException
Unzip the specified input stream.

Parameters:
in - The input stream to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
Throws:
IOException

unzip

public void unzip(ZipInputStream in,
                  File base_folder)
           throws IOException
Unzip the specified zip input stream.

Parameters:
in - The zip input stream to unzip.
base_folder - The base folder to unzip into (will be created if necessary).
Throws:
IOException