codesimian
Class Zips

java.lang.Object
  extended by codesimian.Zips
Direct Known Subclasses:
Jars

public class Zips
extends java.lang.Object

static functions relevant to zip files. For example, jar is a type of zip, and you can rename any .jar file to .zip and it works as a normal .zip file.


Method Summary
static byte[] get1FileFromZip(java.lang.String filePathNameInZip, byte[] zipBytes)
           
static java.lang.String[] getFileNames(byte[] zipBytes)
          TODO: for efficiency, dont read the bytes, get only the names
static Jars.ZipEntryAndByteArray[] unzip(java.util.zip.ZipInputStream zipIn)
          unzip all files in zipIn
static byte[] zipCsArray(CS[] namesAndByteArrays)
          for all CS in namesAndByteArrays[]: use CS.name() and (byte[]) CS.L(byte[].class)
static byte[] zipFileOrFolder(java.io.File fileOrFolder)
           
static byte[] zipFileOrFolder(java.io.File fileOrFolder, int compressionLevel0None9Most, java.lang.String commentOfZipFile)
          Zips 1 file or if its a folder, zips everything in that folder recursively.
static void zipPathNameSaveToPathName(java.lang.String fileOrFolderPathName, java.lang.String saveToThisFilePathName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

zipPathNameSaveToPathName

public static void zipPathNameSaveToPathName(java.lang.String fileOrFolderPathName,
                                             java.lang.String saveToThisFilePathName)
                                      throws java.io.IOException
Throws:
java.io.IOException

zipFileOrFolder

public static byte[] zipFileOrFolder(java.io.File fileOrFolder)
                              throws java.io.IOException
Throws:
java.io.IOException

zipFileOrFolder

public static byte[] zipFileOrFolder(java.io.File fileOrFolder,
                                     int compressionLevel0None9Most,
                                     java.lang.String commentOfZipFile)
                              throws java.io.IOException
Zips 1 file or if its a folder, zips everything in that folder recursively. Returns the bytes of a zip or jar file. For any x.jar, you can rename x.jar to x.zip and it works as a zip file. TEMPORARILY NO COMPRESSION LEVEL CHANGE OR COMMENTS. TEST THIS FIRST.

Throws:
java.io.IOException

zipCsArray

public static byte[] zipCsArray(CS[] namesAndByteArrays)
for all CS in namesAndByteArrays[]: use CS.name() and (byte[]) CS.L(byte[].class)


getFileNames

public static java.lang.String[] getFileNames(byte[] zipBytes)
TODO: for efficiency, dont read the bytes, get only the names


unzip

public static Jars.ZipEntryAndByteArray[] unzip(java.util.zip.ZipInputStream zipIn)
unzip all files in zipIn


get1FileFromZip

public static byte[] get1FileFromZip(java.lang.String filePathNameInZip,
                                     byte[] zipBytes)