org.jmol.util
Class ZipUtil
java.lang.Object
org.jmol.util.ZipUtil
public class ZipUtil
- extends Object
Method Summary |
static void |
getAllData(InputStream is,
String[] subfileList,
String name0,
String binaryFileList,
Hashtable fileData)
reads a ZIP file and saves all data in a Hashtable
so that the files may be organized later in a different order. |
static String |
getBinaryStringForBytes(byte[] bytes)
|
static String |
getGzippedBytesAsString(byte[] bytes)
|
static ZipInputStream |
getStream(InputStream is)
|
static String[] |
getZipDirectoryAndClose(InputStream is,
boolean addManifest)
|
static String |
getZipDirectoryAsStringAndClose(InputStream is)
|
private static String[] |
getZipDirectoryOrErrorAndClose(InputStream is,
boolean addManifest)
|
static byte[] |
getZipEntryAsBytes(ZipInputStream zis)
|
static String |
getZipEntryAsString(InputStream is)
|
static Object |
getZipFileContents(InputStream is,
String[] list,
int listPtr,
boolean asBufferedInputStream)
iteratively drills into zip files of zip files to extract file content
or zip file directory. |
static byte[] |
getZipFileContentsAsBytes(InputStream is,
String[] list,
int listPtr)
|
static boolean |
isGzip(byte[] bytes)
|
static boolean |
isGzip(InputStream is)
|
static boolean |
isJmolManifest(String thisEntry)
|
static boolean |
isZipFile(byte[] bytes)
|
static boolean |
isZipFile(InputStream is)
|
static boolean |
isZipFile(String filePath)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ZipUtil
public ZipUtil()
isZipFile
public static boolean isZipFile(String filePath)
isZipFile
public static boolean isZipFile(InputStream is)
throws Exception
- Throws:
Exception
isZipFile
public static boolean isZipFile(byte[] bytes)
throws Exception
- Throws:
Exception
getStream
public static ZipInputStream getStream(InputStream is)
getAllData
public static void getAllData(InputStream is,
String[] subfileList,
String name0,
String binaryFileList,
Hashtable fileData)
- reads a ZIP file and saves all data in a Hashtable
so that the files may be organized later in a different order. Also adds
a #Directory_Listing entry.
Files are bracketed by BEGIN Directory Entry and END Directory Entry lines,
similar to CompoundDocument.getAllData.
- Parameters:
is
- subfileList
- name0
- prefix for entry listingbinaryFileList
- |-separated list of files that should be saved
as xx xx xx hex byte strings. The directory listing
is appended with ":asBinaryString"fileData
-
getBinaryStringForBytes
public static String getBinaryStringForBytes(byte[] bytes)
getZipFileContents
public static Object getZipFileContents(InputStream is,
String[] list,
int listPtr,
boolean asBufferedInputStream)
- iteratively drills into zip files of zip files to extract file content
or zip file directory. Also works with JAR files.
Does not return "__MACOS" paths
- Parameters:
is
- list
- listPtr
- asBufferedInputStream
- for Pmesh
- Returns:
- directory listing or subfile contents
getZipFileContentsAsBytes
public static byte[] getZipFileContentsAsBytes(InputStream is,
String[] list,
int listPtr)
getZipDirectoryAsStringAndClose
public static String getZipDirectoryAsStringAndClose(InputStream is)
getZipDirectoryAndClose
public static String[] getZipDirectoryAndClose(InputStream is,
boolean addManifest)
isJmolManifest
public static boolean isJmolManifest(String thisEntry)
getZipDirectoryOrErrorAndClose
private static String[] getZipDirectoryOrErrorAndClose(InputStream is,
boolean addManifest)
throws IOException
- Throws:
IOException
getZipEntryAsString
public static String getZipEntryAsString(InputStream is)
throws IOException
- Throws:
IOException
getZipEntryAsBytes
public static byte[] getZipEntryAsBytes(ZipInputStream zis)
throws IOException
- Throws:
IOException
isGzip
public static boolean isGzip(byte[] bytes)
isGzip
public static boolean isGzip(InputStream is)
throws Exception
- Throws:
Exception
getGzippedBytesAsString
public static String getGzippedBytesAsString(byte[] bytes)