Compiere 3.1

org.compiere.util
Class ZipUtil

java.lang.Object
  extended by org.compiere.util.ZipUtil

public class ZipUtil
extends Object

Zip/Jar File Utilities

Version:
$Id: ZipUtil.java,v 1.2 2006/07/30 00:54:36 jjanke Exp $
Author:
Jorg Janke

Constructor Summary
ZipUtil()
          Empty Constructor, need to open explicitly.
ZipUtil(File file)
          Open zip file.
ZipUtil(String fileName)
          Open zip file.
ZipUtil(URI uri)
          Open zip file.
 
Method Summary
 void close()
          Close Zip File
static void dumpManifest(String fileName)
          Dump Manifest to
 Enumeration<? extends ZipEntry> entries()
          Get ZipEntries as Enumeration
static String findInPath(String jarFile)
          Get Fill name of jarfile in path
 String[] getContent()
          Get Content as sorted String Array
 ZipEntry getEntry(String name)
          Get Zip Entry
static ZipEntry getEntry(String fileName, String entryName)
          Get Zip Entry
 String getEntryInfo(String name)
          Get File Info
static String getEntryTime(String fileName, String entryName)
          Get Zip Entry time
 InputStream getInputStream(ZipEntry zipEntry)
          Get the input stream for reading the content of the zip file entry
 JarFile getJar()
          Get it as Jar if it is a Jar
static JarFile getJar(String fileName)
          Get Jar File
static JarEntry getJarEntry(String fileName, String jarEntry)
          Get Manifest
 Manifest getManifest()
          Get Manifest if a Jar
static Manifest getManifest(String fileName)
          Get Manifest
 boolean isJar()
          Is it a Jar
 boolean isOpen()
          Is the Zip File Open
static void main(String[] args)
          Test
 boolean open(File file)
          Open the Zip File for reading
 boolean open(String fileName)
          Open the Zip File for reading
 boolean open(URI uri)
          Open the Zip File for reading
 String toString()
          String Representation
 boolean writeToFile(ZipEntry zipEntry, String fileName)
          Write Entry to File
 File writeToTemp(ZipEntry zipEntry)
          Write Entry to File
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZipUtil

public ZipUtil()
Empty Constructor, need to open explicitly.


ZipUtil

public ZipUtil(String fileName)
Open zip file.

Parameters:
fileName - zip file name

ZipUtil

public ZipUtil(File file)
Open zip file.

Parameters:
file - zip file

ZipUtil

public ZipUtil(URI uri)
Open zip file.

Parameters:
fileName - zip file name
Method Detail

open

public boolean open(URI uri)
Open the Zip File for reading

Parameters:
fileName - zip file
Returns:
true if opened

open

public boolean open(String fileName)
Open the Zip File for reading

Parameters:
fileName - zip file
Returns:
true if opened

open

public boolean open(File file)
Open the Zip File for reading

Parameters:
file - zip file
Returns:
true if opened

close

public void close()
Close Zip File


isOpen

public boolean isOpen()
Is the Zip File Open

Returns:
true if yes

isJar

public boolean isJar()
Is it a Jar

Returns:
true if yes

getJar

public JarFile getJar()
Get it as Jar if it is a Jar

Returns:
jar or null if not a jar

toString

public String toString()
String Representation

Overrides:
toString in class Object
Returns:
info

getContent

public String[] getContent()
Get Content as sorted String Array

Returns:
content

entries

public Enumeration<? extends ZipEntry> entries()
Get ZipEntries as Enumeration

Returns:
entries

getInputStream

public InputStream getInputStream(ZipEntry zipEntry)
                           throws IOException
Get the input stream for reading the content of the zip file entry

Returns:
InputStream
Throws:
IOException

writeToFile

public boolean writeToFile(ZipEntry zipEntry,
                           String fileName)
Write Entry to File

Parameters:
zipEntry - entry
fileName - absolute path of the file
Returns:
true if success

writeToTemp

public File writeToTemp(ZipEntry zipEntry)
Write Entry to File

Parameters:
zipEntry - entry
Returns:
temporary File or null

getEntry

public ZipEntry getEntry(String name)
Get Zip Entry

Parameters:
name - entry name
Returns:
ZipEntry or null if not found

getEntryInfo

public String getEntryInfo(String name)
Get File Info

Parameters:
name - name
Returns:
time and size

getManifest

public Manifest getManifest()
Get Manifest if a Jar

Returns:
Manifest if exists or null

getEntry

public static ZipEntry getEntry(String fileName,
                                String entryName)
Get Zip Entry

Parameters:
fileName - zip/jar file
entryName - entry
Returns:
ZipEntry

getJar

public static JarFile getJar(String fileName)
Get Jar File

Parameters:
fileName - zip/jar file
Returns:
Jar

getManifest

public static Manifest getManifest(String fileName)
Get Manifest

Parameters:
fileName - zip/jar file
Returns:
Manifest or null

getJarEntry

public static JarEntry getJarEntry(String fileName,
                                   String jarEntry)
Get Manifest

Parameters:
fileName - jar file
jarEntry - jar entry
Returns:
Manifest

dumpManifest

public static void dumpManifest(String fileName)
Dump Manifest to

Parameters:
fileName - zip/jar file

getEntryTime

public static String getEntryTime(String fileName,
                                  String entryName)
Get Zip Entry time

Parameters:
fileName - zip file
entryName - entry
Returns:
Time as String or null

findInPath

public static String findInPath(String jarFile)
Get Fill name of jarfile in path

Parameters:
jarFile - name
Returns:
full name or null if not found

main

public static void main(String[] args)
Test

Parameters:
args - ignored

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.