it.geosolutions.tools.compress.file
Class Compressor

java.lang.Object
  extended by it.geosolutions.tools.compress.file.Compressor

public final class Compressor
extends Object


Constructor Summary
Compressor()
           
 
Method Summary
static File deflate(File inputDir, String zipFilePrefix)
          Zip all the files in the input directory which starts with the provided prefix.
static File deflate(File outputDir, String zipFileBaseName, File[] files)
           
static void inflate(ZipFile archive, File outputDirectory, String fileName)
          Inflate the provided ZipFile in the provided output directory.
static File zip(File outputDir, String zipFileBaseName, File[] files)
          This function zip the input files.
static void zipDirectory(File directory, File base, ZipOutputStream out)
          This function zip the input directory.
static void zipFile(File file, ZipOutputStream out)
          This function zip the input file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compressor

public Compressor()
Method Detail

deflate

public static File deflate(File inputDir,
                           String zipFilePrefix)
Zip all the files in the input directory which starts with the provided prefix.

Parameters:
inputDir - directory where to get files from.
zipFilePrefix - prefix to choose files.
Returns:
a File that points to the generated zip file, or null.

deflate

public static File deflate(File outputDir,
                           String zipFileBaseName,
                           File[] files)
Parameters:
outputDir - The directory where the zipfile will be created
zipFileBaseName - The basename of hte zip file (i.e.: a .zip will be appended)
files - The files that will be put into the zipfile
Returns:
The created zipfile, or null if an error occurred.

zip

public static File zip(File outputDir,
                       String zipFileBaseName,
                       File[] files)
                throws IOException
This function zip the input files.

Parameters:
outputDir - The temporary directory where the zip files.
zipFileBaseName - The name of the zip file.
files - The array files to zip.
Returns:
The zip file or null.
Throws:
IOException

zipDirectory

public static void zipDirectory(File directory,
                                File base,
                                ZipOutputStream out)
                         throws IOException
This function zip the input directory.

Parameters:
directory - The directory to be zipped.
base - The base directory.
out - The zip output stream.
Throws:
IOException

zipFile

public static void zipFile(File file,
                           ZipOutputStream out)
                    throws IOException
This function zip the input file.

Parameters:
file - The input file to be zipped.
out - The zip output stream.
Throws:
IOException

inflate

public static void inflate(ZipFile archive,
                           File outputDirectory,
                           String fileName)
                    throws IOException,
                           FileNotFoundException
Inflate the provided ZipFile in the provided output directory.

Parameters:
archive - the ZipFile to inflate.
outputDirectory - the directory where to inflate the archive.
Throws:
IOException - in case something bad happens.
FileNotFoundException - in case something bad happens.


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.