pl.psnc.dl.ege.utils
Class EGEIOUtils

java.lang.Object
  extended by pl.psnc.dl.ege.utils.EGEIOUtils

public final class EGEIOUtils
extends java.lang.Object

Pack of usable EGE IO utilities. TODO : switch to external IO Utilities (e.g. from Vesta or Apache Commons)

Author:
mariuszs

Method Summary
static void constructZip(java.io.File file, java.util.zip.ZipOutputStream out, java.lang.String dir)
          Construct zip file from specified dir location.
static void copyStream(java.io.InputStream is, java.io.OutputStream os)
          Perform copy from input stream to output stream.
static boolean deleteDirectory(java.io.File dir)
          Deletes a directory.
static boolean isComplexZip(java.io.File zipFile)
          Checks if specified zip content contains more than one file.
static void unzipFile(java.util.zip.ZipFile zipFile, java.io.File destinationDir)
          Extracts content of the zipFile to given destination directory
static void unzipSingleFile(java.util.zip.ZipFile zipFile, java.io.OutputStream os)
          Unpacks single file data to stream.
static void unzipStream(java.io.InputStream in, java.io.File outputDir)
          Unzips a zip compressed file to some output directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

constructZip

public static void constructZip(java.io.File file,
                                java.util.zip.ZipOutputStream out,
                                java.lang.String dir)
                         throws java.io.IOException
Construct zip file from specified dir location. Result is transfered into ZipOutputStream.

Parameters:
file - directory to pack
out - zip output stream
dir - used for zip entries
Throws:
java.io.IOException

deleteDirectory

public static boolean deleteDirectory(java.io.File dir)
Deletes a directory.

Parameters:
dir - The directory to delete
Returns:
Returns true on success.

copyStream

public static void copyStream(java.io.InputStream is,
                              java.io.OutputStream os)
                       throws java.io.IOException
Perform copy from input stream to output stream.

Parameters:
is - source stream
os - result stream
Throws:
java.io.IOException

unzipFile

public static void unzipFile(java.util.zip.ZipFile zipFile,
                             java.io.File destinationDir)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Extracts content of the zipFile to given destination directory

Parameters:
zipFile - the file to unzip
destinationDir - destination directory for the content of the zipFile
Throws:
java.io.FileNotFoundException - if a file could not be created
java.io.IOException - if IO error occurs

unzipStream

public static void unzipStream(java.io.InputStream in,
                               java.io.File outputDir)
                        throws java.io.FileNotFoundException,
                               java.io.IOException
Unzips a zip compressed file to some output directory.

Parameters:
in - The InputStream.
outputDir - The output directory.
Throws:
java.io.IOException
java.io.FileNotFoundException

isComplexZip

public static boolean isComplexZip(java.io.File zipFile)
                            throws java.io.IOException
Checks if specified zip content contains more than one file.

Parameters:
zipFile -
Returns:
Throws:
java.io.IOException

unzipSingleFile

public static void unzipSingleFile(java.util.zip.ZipFile zipFile,
                                   java.io.OutputStream os)
                            throws java.io.IOException
Unpacks single file data to stream. Should be only used when expecting single file in zip package.

Parameters:
zipFile -
os -
Throws:
java.io.IOException


Copyright © 2010. All Rights Reserved.