Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.common.utils
Class ZipUtils

java.lang.Object
  extended by org.nuxeo.common.utils.ZipUtils

public final class ZipUtils
extends Object

Author:
bstefanescu

Method Summary
static void _putDirectoryEntry(String entryName, ZipOutputStream out)
           
static void _putFileEntry(File file, String entryName, ZipOutputStream out)
           
static void _zip(File[] files, ZipOutputStream out, String prefix)
           
static void _zip(String entryName, File file, ZipOutputStream out)
           
static void _zip(String entryName, InputStream in, ZipOutputStream out)
           
static byte[] getEntryContentAsBytes(File file, String entryName)
          Unzips directly the entry.
static byte[] getEntryContentAsBytes(InputStream stream, String searchedEntryName)
           
static byte[] getEntryContentAsBytes(URL url, String entryName)
           
static InputStream getEntryContentAsStream(File file, String entryName)
          Unzip directly the entry.
static InputStream getEntryContentAsStream(InputStream stream, String entryName)
           
static InputStream getEntryContentAsStream(URL url, String entryName)
           
static String getEntryContentAsString(File file, String entryName)
          Unzip directly the entry.
static String getEntryContentAsString(InputStream stream, String searchedEntryName)
           
static String getEntryContentAsString(URL url, String entryName)
           
static List<String> getEntryNames(File file)
          Lists the entries on the zip file.
static List<String> getEntryNames(InputStream stream)
           
static List<String> getEntryNames(URL url)
           
static boolean hasEntry(File file, String entryName)
          Checks if a zip file contains a specified entry name.
static boolean hasEntry(InputStream stream, String entryName)
           
static boolean hasEntry(URL url, String entryName)
           
static void unzip(File zip, File dir)
           
static void unzip(File zip, File dir, PathFilter filter)
           
static void unzip(InputStream zipStream, File dir)
           
static void unzip(String prefix, File zip, File dir)
           
static void unzip(String prefix, File zip, File dir, PathFilter filter)
           
static void unzip(String prefix, InputStream zipStream, File dir)
           
static void unzip(String prefix, URL zip, File dir)
           
static void unzip(String prefix, ZipInputStream in, File dir)
           
static void unzip(String prefix, ZipInputStream in, File dir, PathFilter filter)
           
static void unzip(URL zip, File dir)
           
static void unzip(ZipInputStream in, File dir)
           
static void unzip(ZipInputStream in, File dir, PathFilter filter)
           
static void unzipIgnoreDirs(InputStream zipStream, File dir)
           
static void unzipIgnoreDirs(ZipInputStream in, File dir)
           
static void zip(File[] files, File zip)
           
static void zip(File[] files, File zip, String prefix)
           
static void zip(File[] files, OutputStream out, String prefix)
           
static void zip(File file, File zip)
           
static void zip(File file, File zip, String prefix)
           
static void zip(File file, OutputStream out, String prefix)
           
static void zipFilesUsingPrefix(String prefix, File[] files, OutputStream out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

_putDirectoryEntry

public static void _putDirectoryEntry(String entryName,
                                      ZipOutputStream out)
                               throws IOException
Throws:
IOException

_putFileEntry

public static void _putFileEntry(File file,
                                 String entryName,
                                 ZipOutputStream out)
                          throws IOException
Throws:
IOException

_zip

public static void _zip(String entryName,
                        InputStream in,
                        ZipOutputStream out)
                 throws IOException
Throws:
IOException

_zip

public static void _zip(String entryName,
                        File file,
                        ZipOutputStream out)
                 throws IOException
Throws:
IOException

_zip

public static void _zip(File[] files,
                        ZipOutputStream out,
                        String prefix)
                 throws IOException
Throws:
IOException

zip

public static void zip(File file,
                       OutputStream out,
                       String prefix)
                throws IOException
Throws:
IOException

zip

public static void zip(File[] files,
                       OutputStream out,
                       String prefix)
                throws IOException
Throws:
IOException

zip

public static void zip(File file,
                       File zip)
                throws IOException
Throws:
IOException

zip

public static void zip(File[] files,
                       File zip)
                throws IOException
Throws:
IOException

zip

public static void zip(File file,
                       File zip,
                       String prefix)
                throws IOException
Throws:
IOException

zip

public static void zip(File[] files,
                       File zip,
                       String prefix)
                throws IOException
Throws:
IOException

zipFilesUsingPrefix

public static void zipFilesUsingPrefix(String prefix,
                                       File[] files,
                                       OutputStream out)
                                throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         InputStream zipStream,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(InputStream zipStream,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         URL zip,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(URL zip,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         File zip,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(File zip,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         ZipInputStream in,
                         File dir)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(ZipInputStream in,
                         File dir)
                  throws IOException
Throws:
IOException

unzipIgnoreDirs

public static void unzipIgnoreDirs(ZipInputStream in,
                                   File dir)
                            throws IOException
Throws:
IOException

unzipIgnoreDirs

public static void unzipIgnoreDirs(InputStream zipStream,
                                   File dir)
                            throws IOException
Throws:
IOException

unzip

public static void unzip(File zip,
                         File dir,
                         PathFilter filter)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(ZipInputStream in,
                         File dir,
                         PathFilter filter)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         File zip,
                         File dir,
                         PathFilter filter)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(String prefix,
                         ZipInputStream in,
                         File dir,
                         PathFilter filter)
                  throws IOException
Throws:
IOException

getEntryContentAsStream

public static InputStream getEntryContentAsStream(File file,
                                                  String entryName)
                                           throws IOException
Unzip directly the entry. The returned InputStream has to be closed.

Parameters:
file - the source file
entryName - the entry name that has to be extracted
Returns:
the input stream of the desired entry - has to be closed by the caller, or null if not found
Throws:
IOException

getEntryContentAsString

public static String getEntryContentAsString(File file,
                                             String entryName)
                                      throws IOException
Unzip directly the entry.

Parameters:
file - the source file
entryName - the entry name that has to be extracted
Returns:
the String content of the entry with name entryName
Throws:
IOException

getEntryContentAsBytes

public static byte[] getEntryContentAsBytes(File file,
                                            String entryName)
                                     throws IOException
Unzips directly the entry.

Parameters:
file - the source file
entryName - the entry name that has to be extracted
Returns:
The byte array content of the entry with name entryName
Throws:
IOException

getEntryNames

public static List<String> getEntryNames(File file)
                                  throws IOException
Lists the entries on the zip file.

Parameters:
file - The zip file
Returns:
The list of entries
Throws:
IOException

hasEntry

public static boolean hasEntry(File file,
                               String entryName)
                        throws IOException
Checks if a zip file contains a specified entry name.

Parameters:
file - the zip file
entryName - The content to be checked
Returns:
True if the file contains entryName. False otherwise
Throws:
IOException

getEntryContentAsStream

public static InputStream getEntryContentAsStream(InputStream stream,
                                                  String entryName)
                                           throws IOException
Throws:
IOException

getEntryContentAsString

public static String getEntryContentAsString(InputStream stream,
                                             String searchedEntryName)
                                      throws IOException
Throws:
IOException

getEntryContentAsBytes

public static byte[] getEntryContentAsBytes(InputStream stream,
                                            String searchedEntryName)
                                     throws IOException
Throws:
IOException

getEntryNames

public static List<String> getEntryNames(InputStream stream)
                                  throws IOException
Throws:
IOException

hasEntry

public static boolean hasEntry(InputStream stream,
                               String entryName)
                        throws IOException
Throws:
IOException

getEntryContentAsStream

public static InputStream getEntryContentAsStream(URL url,
                                                  String entryName)
                                           throws IOException
Throws:
IOException

getEntryContentAsString

public static String getEntryContentAsString(URL url,
                                             String entryName)
                                      throws IOException
Throws:
IOException

getEntryContentAsBytes

public static byte[] getEntryContentAsBytes(URL url,
                                            String entryName)
                                     throws IOException
Throws:
IOException

getEntryNames

public static List<String> getEntryNames(URL url)
                                  throws IOException
Throws:
IOException

hasEntry

public static boolean hasEntry(URL url,
                               String entryName)
                        throws IOException
Throws:
IOException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.