com.silverpeas.util
Class ZipManager

java.lang.Object
  extended by com.silverpeas.util.ZipManager

public class ZipManager
extends Object

Classe contenant des méthodes statiques de gestion des fichiers zip

Author:
sdevolder

Constructor Summary
ZipManager()
           
 
Method Summary
static long compressFile(String filePath, String zipFilePath)
          Compress a file into a zip file.
static long compressPathToZip(File folderToZip, File zipFile)
          Méthode compressant un dossier de façon récursive au format zip.
static long compressPathToZip(String folderToZip, String zipFile)
          Méthode compressant un dossier de façon récursive au format zip.
static void compressStreamToZip(InputStream inputStream, String filePathNameToCreate, String outfilename)
          Méthode permettant la création et l'organisation d'un fichier zip en lui passant directement un flux d'entrée
static void extract(File source, File dest)
          Extract the content of an archive into a directory.
static int getNbFiles(File archive)
          Indicates the number of files (not directories) inside the archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipManager

public ZipManager()
Method Detail

compressFile

public static long compressFile(String filePath,
                                String zipFilePath)
                         throws IOException
Compress a file into a zip file.

Parameters:
filePath -
zipFilePath -
Returns:
Throws:
IOException

compressPathToZip

public static long compressPathToZip(String folderToZip,
                                     String zipFile)
                              throws IOException
Méthode compressant un dossier de façon récursive au format zip.

Parameters:
folderToZip - - dossier à compresser
zipFile - - fichier zip à creer
Returns:
la taille du fichier zip généré en octets
Throws:
FileNotFoundException
IOException

compressPathToZip

public static long compressPathToZip(File folderToZip,
                                     File zipFile)
                              throws IOException
Méthode compressant un dossier de façon récursive au format zip.

Parameters:
folderToZip - - dossier à compresser
zipFile - - fichier zip à creer
Returns:
la taille du fichier zip généré en octets
Throws:
FileNotFoundException
IOException

compressStreamToZip

public static void compressStreamToZip(InputStream inputStream,
                                       String filePathNameToCreate,
                                       String outfilename)
                                throws IOException
Méthode permettant la création et l'organisation d'un fichier zip en lui passant directement un flux d'entrée

Parameters:
inputStream - - flux de données à enregistrer dans le zip
filePathNameToCreate - - chemin et nom du fichier porté par les données du flux dans le zip
outfilename - - chemin et nom du fichier zip à creer ou compléter
Throws:
IOException

extract

public static void extract(File source,
                           File dest)
                    throws UtilException
Extract the content of an archive into a directory.

Parameters:
source - the archive.
dest - the destination directory.
Throws:
UtilException

getNbFiles

public static int getNbFiles(File archive)
Indicates the number of files (not directories) inside the archive.

Parameters:
archive - the archive whose content is analyzed.
Returns:
the number of files (not directories) inside the archive.


Copyright © 2016 Silverpeas. All Rights Reserved.