Download Java Zip File
- Class
Class ZipFile
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. The java.util.zip.ZipFile class is used to read entries from a zip file. Class declaration. Following is the declaration for java.util.zip.ZipFile class − public class ZipFile extends Object implements Closeable Fields. Download pages for older mac. Following are the fields for java.util.zip.ZipFile class − static int CENATT. Static int CENATX. Static int CENCOM. To allow the Java Runtime Environment to run codes, the Java Development Kit includes debuggers that test and find errors in the written language as well as the Java Compiler to compile the codes. /imessage-for-mac-download.html. The Java Virtual Machine is included in the Java Runtime Environment package because the JRE software uses the JVM to run compiled codes. Java SE Runtime Environment 8 Downloads. Do you want to run Java™ programs, or do you want to develop Java programs? If you want to run Java programs, but not develop them, download the Java Runtime Environment, or JRE™.
- java.util.zip.ZipFile
- All Implemented Interfaces:
- Closeable, AutoCloseable
- Direct Known Subclasses:
- JarFile
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.
Java 8 Zip File Download
Field Summary
Fields Modifier and Type Field and Description static int
CENATT
static int
CENATX
static int
CENCOM
static int
CENCRC
static int
CENDSK
static int
CENEXT
static int
CENFLG
static int
CENHDR
static int
CENHOW
static int
CENLEN
static int
CENNAM
static int
CENOFF
static long
CENSIG
static int
CENSIZ
static int
CENTIM
static int
CENVEM
static int
CENVER
static int
ENDCOM
static int
ENDHDR
static int
ENDOFF
static long
ENDSIG
static int
ENDSIZ
static int
ENDSUB
static int
ENDTOT
static int
EXTCRC
static int
EXTHDR
static int
EXTLEN
static long
EXTSIG
static int
EXTSIZ
static int
LOCCRC
static int
LOCEXT
static int
LOCFLG
static int
LOCHDR
static int
LOCHOW
static int
LOCLEN
static int
LOCNAM
static long
LOCSIG
static int
LOCSIZ
static int
LOCTIM
static int
LOCVER
static int
OPEN_DELETE
Mode flag to open a zip file and mark it for deletion.static int
OPEN_READ
Constructor Summary
Constructors Constructor and Description ZipFile(File file)
Opens a ZIP file for reading given the specified File object.ZipFile(File file, Charset charset)
Opens a ZIP file for reading given the specified File object.ZipFile(File file, int mode)
Opens a newZipFile
to read from the specifiedFile
object in the specified mode.ZipFile(File file, int mode, Charset charset)
Opens a newZipFile
to read from the specifiedFile
object in the specified mode.ZipFile(String name)
ZipFile(String name, Charset charset)
Opens a zip file for reading.
Method Summary
Methods Modifier and Type Method and Description void
close()
Enumeration<? extends ZipEntry>
entries()
Returns an enumeration of the ZIP file entries.protected void
finalize()
Ensures that the system resources held by this ZipFile object are released when there are no more references to it.String
getComment()
ZipEntry
getEntry(String name)
Returns the zip file entry for the specified name, or null if not found.InputStream
getInputStream(ZipEntry entry)
Returns an input stream for reading the contents of the specified zip file entry.String
getName()
int
size()
Returns the number of entries in the ZIP file.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
OPEN_READ
- See Also:
- Constant Field Values
OPEN_DELETE
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.- See Also:
- Constant Field Values
LOCSIG
- See Also:
- Constant Field Values
EXTSIG
- See Also:
- Constant Field Values
CENSIG
- See Also:
- Constant Field Values
ENDSIG
- See Also:
- Constant Field Values
LOCHDR
- See Also:
- Constant Field Values
EXTHDR
- See Also:
- Constant Field Values
CENHDR
- See Also:
- Constant Field Values
ENDHDR
- See Also:
- Constant Field Values
LOCVER
- See Also:
- Constant Field Values
LOCFLG
- See Also:
- Constant Field Values
LOCHOW
- See Also:
- Constant Field Values
LOCTIM
- See Also:
- Constant Field Values
LOCCRC
- See Also:
- Constant Field Values
LOCSIZ
- See Also:
- Constant Field Values
LOCLEN
- See Also:
- Constant Field Values
LOCNAM
- See Also:
- Constant Field Values
LOCEXT
- See Also:
- Constant Field Values
EXTCRC
- See Also:
- Constant Field Values
EXTSIZ
- See Also:
- Constant Field Values
EXTLEN
- See Also:
- Constant Field Values
CENVEM
- See Also:
- Constant Field Values
CENVER
- See Also:
- Constant Field Values
CENFLG
- See Also:
- Constant Field Values
CENHOW
- See Also:
- Constant Field Values
CENTIM
- See Also:
- Constant Field Values
CENCRC
- See Also:
- Constant Field Values
CENSIZ
- See Also:
- Constant Field Values
CENLEN
- See Also:
- Constant Field Values
CENNAM
- See Also:
- Constant Field Values
CENEXT
- See Also:
- Constant Field Values
CENCOM
- See Also:
- Constant Field Values
CENDSK
- See Also:
- Constant Field Values
CENATT
- See Also:
- Constant Field Values
CENATX
- See Also:
- Constant Field Values
CENOFF
- See Also:
- Constant Field Values
ENDSUB
- See Also:
- Constant Field Values
ENDTOT
- See Also:
- Constant Field Values
ENDSIZ
- See Also:
- Constant Field Values
ENDOFF
- See Also:
- Constant Field Values
ENDCOM
- See Also:
- Constant Field Values
Constructor Detail
ZipFile
Opens a zip file for reading.First, if there is a security manager, its
checkRead
method is called with thename
argument as its argument to ensure the read is allowed.The UTF-8
charset
is used to decode the entry names and comments.- Parameters:
name
- the name of the zip file- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurredSecurityException
- if a security manager exists and itscheckRead
method doesn't allow read access to the file.- See Also:
SecurityManager.checkRead(java.lang.String)
ZipFile
Opens a newZipFile
to read from the specifiedFile
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 thename
argument as its argument to ensure the read is allowed.The UTF-8
charset
is used to decode the entry names and comments- Parameters:
file
- the ZIP file to be opened for readingmode
- the mode in which the file is to be opened- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurredSecurityException
- if a security manager exists and itscheckRead
method doesn't allow read access to the file, or itscheckDelete
method doesn't allow deleting the file when the OPEN_DELETE flag is set.IllegalArgumentException
- if the mode argument is invalid- Since:
- 1.3
- See Also:
SecurityManager.checkRead(java.lang.String)
ZipFile
Opens a ZIP file for reading given the specified File object.The UTF-8
charset
is used to decode the entry names and comments.- Parameters:
file
- the ZIP file to be opened for reading- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurred
ZipFile
Opens a newZipFile
to read from the specifiedFile
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 thename
argument as its argument to ensure the read is allowed.- Parameters:
file
- the ZIP file to be opened for readingmode
- the mode in which the file is to be openedcharset
- the charset to be used to decode the ZIP entry name and comment that are not encoded by using UTF-8 encoding (indicated by entry's general purpose flag).- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurredSecurityException
- if a security manager exists and itscheckRead
method doesn't allow read access to the file,or itscheckDelete
method doesn't allow deleting the file when the OPEN_DELETE flag is setIllegalArgumentException
- if the mode argument is invalid- Since:
- 1.7
- See Also:
SecurityManager.checkRead(java.lang.String)
ZipFile
Opens a zip file for reading.First, if there is a security manager, its
checkRead
method is called with thename
argument as its argument to ensure the read is allowed.- Parameters:
name
- the name of the zip filecharset
- the charset to be used to decode the ZIP entry name and comment that are not encoded by using UTF-8 encoding (indicated by entry's general purpose flag).- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurredSecurityException
- if a security manager exists and itscheckRead
method doesn't allow read access to the file- Since:
- 1.7
- See Also:
SecurityManager.checkRead(java.lang.String)
ZipFile
Opens a ZIP file for reading given the specified File object.- Parameters:
file
- the ZIP file to be opened for readingcharset
- The charset to be used to decode the ZIP entry name and comment (ignored if the language encoding bit of the ZIP entry's general purpose bit flag is set).- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurred- Since:
- 1.7
Method Detail
getComment
- Returns:
- the comment string for the zip file, or null if none
- Throws:
IllegalStateException
- if the zip file has been closed Since 1.7
getEntry
Returns the zip file entry for the specified name, or null if not found.- Parameters:
name
- the name of the entry- Returns:
- the zip file entry, or null if not found
- Throws:
IllegalStateException
- if the zip file has been closed
getInputStream
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- Returns:
- the input stream for reading the contents of the specified zip file entry.
- Throws:
ZipException
- if a ZIP format error has occurredIOException
- if an I/O error has occurredIllegalStateException
- if the zip file has been closed
getName
- Returns:
- the path name of the ZIP file
entries
Returns an enumeration of the ZIP file entries.- Returns:
- an enumeration of the ZIP file entries
- Throws:
IllegalStateException
- if the zip file has been closed
size
- Returns:
- the number of entries in the ZIP file
- Throws:
IllegalStateException
- if the zip file has been closed
close
Closes the ZIP file.Closing this ZIP file will close all of the input streams previously returned by invocations of the
getInputStream
Incredimail 2.5 crack. method.- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- if an I/O error has occurred
finalize
Ensures that the system resources held by this ZipFile object are released 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 thisZipFile
. This will prevent holding up system resources for an undetermined length of time.- Overrides:
finalize
in classObject
- Throws:
IOException
- if an I/O error has occurred- See Also:
close()
- Class
Download Java Zip File Viewer
- Summary:
- Nested
- Field
- Constr
- Detail:
- Field
- Constr
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Java Zip File Example
Scripting on this page tracks web page traffic, but does not change the content in any way.