Java Doc for ZipFile.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » zip » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.zip 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.zip.ZipFile

All known Subclasses:   java.util.jar.JarFile,
ZipFile
public class ZipFile implements ZipConstants(Code)
This class is used to read entries from a zip file.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.
version:
   1.84, 05/05/07
author:
   David Connelly



Field Summary
final public static  intOPEN_DELETE
     Mode flag to open a zip file and mark it for deletion.
final public static  intOPEN_READ
     Mode flag to open a zip file for reading.

Constructor Summary
public  ZipFile(String name)
     Opens a zip file for reading.
public  ZipFile(File file, int mode)
     Opens a new ZipFile to read from the specified File object in the specified mode.
public  ZipFile(File file)
     Opens a ZIP file for reading given the specified File object.

Method Summary
public  voidclose()
     Closes the ZIP file.
public  Enumeration<? extends ZipEntry>entries()
     Returns an enumeration of the ZIP file entries.
protected  voidfinalize()
     Ensures that the close method of this ZIP file is called when there are no more references to it.
public  ZipEntrygetEntry(String name)
     Returns the zip file entry for the specified name, or null if not found.
public  InputStreamgetInputStream(ZipEntry entry)
     Returns an input stream for reading the contents of the specified zip file entry.
public  StringgetName()
     Returns the path name of the ZIP file.
public  intsize()
     Returns the number of entries in the ZIP file.

Field Detail
OPEN_DELETE
final public static int OPEN_DELETE(Code)
Mode flag to open a zip file and mark it for deletion. The file will be deleted some time between the moment that it is opened and the moment that it is closed, but its contents will remain accessible via the ZipFile object until either the close method is invoked or the virtual machine exits.



OPEN_READ
final public static int OPEN_READ(Code)
Mode flag to open a zip file for reading.




Constructor Detail
ZipFile
public ZipFile(String name) throws IOException(Code)
Opens a zip file for reading.

First, if there is a security manager, its checkRead method is called with the name argument as its argument to ensure the read is allowed.
Parameters:
  name - the name of the zip file
throws:
  ZipException - if a ZIP format error has occurred
throws:
  IOException - if an I/O error has occurred
throws:
  SecurityException - if a security manager exists and itscheckRead method doesn't allow read access to the file.
See Also:   SecurityManager.checkRead(java.lang.String)




ZipFile
public ZipFile(File file, int mode) throws IOException(Code)
Opens a new ZipFile to read from the specified File object in the specified mode. The mode argument must be either OPEN_READ or OPEN_READ | OPEN_DELETE.

First, if there is a security manager, its checkRead method is called with the name argument as its argument to ensure the read is allowed.
Parameters:
  file - the ZIP file to be opened for reading
Parameters:
  mode - the mode in which the file is to be opened
throws:
  ZipException - if a ZIP format error has occurred
throws:
  IOException - if an I/O error has occurred
throws:
  SecurityException - if a security manager exists andits checkRead methoddoesn't allow read access to the file,or its checkDelete method doesn't allow deletingthe file when the OPEN_DELETE flag is set.
throws:
  IllegalArgumentException - if the mode argument is invalid
See Also:   SecurityManager.checkRead(java.lang.String)
since:
   1.3




ZipFile
public ZipFile(File file) throws ZipException, IOException(Code)
Opens a ZIP file for reading given the specified File object.
Parameters:
  file - the ZIP file to be opened for reading
throws:
  ZipException - if a ZIP error has occurred
throws:
  IOException - if an I/O error has occurred




Method Detail
close
public void close() throws IOException(Code)
Closes the ZIP file.

Closing this ZIP file will close all of the input streams previously returned by invocations of the ZipFile.getInputStreamgetInputStream method.
throws:
  IOException - if an I/O error has occurred




entries
public Enumeration<? extends ZipEntry> entries()(Code)
Returns an enumeration of the ZIP file entries. an enumeration of the ZIP file entries
throws:
  IllegalStateException - if the zip file has been closed



finalize
protected void finalize() throws IOException(Code)
Ensures that the close method of this ZIP file is called when there are no more references to it.

Since the time when GC would invoke this method is undetermined, it is strongly recommended that applications invoke the close method as soon they have finished accessing this ZipFile. This will prevent holding up system resources for an undetermined length of time.
throws:
  IOException - if an I/O error has occurred
See Also:   java.util.zip.ZipFile.close




getEntry
public ZipEntry getEntry(String name)(Code)
Returns the zip file entry for the specified name, or null if not found.
Parameters:
  name - the name of the entry the zip file entry, or null if not found
throws:
  IllegalStateException - if the zip file has been closed



getInputStream
public InputStream getInputStream(ZipEntry entry) throws IOException(Code)
Returns an input stream for reading the contents of the specified zip file entry.

Closing this ZIP file will, in turn, close all input streams that have been returned by invocations of this method.
Parameters:
  entry - the zip file entry the input stream for reading the contents of the specifiedzip file entry.
throws:
  ZipException - if a ZIP format error has occurred
throws:
  IOException - if an I/O error has occurred
throws:
  IllegalStateException - if the zip file has been closed




getName
public String getName()(Code)
Returns the path name of the ZIP file. the path name of the ZIP file



size
public int size()(Code)
Returns the number of entries in the ZIP file. the number of entries in the ZIP file
throws:
  IllegalStateException - if the zip file has been closed



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.