- Open zip files in java
- Field Summary
- Constructor Summary
- Method Summary
- Methods declared in class java.lang.Object
- Field Detail
- OPEN_READ
- OPEN_DELETE
- LOCSIG
- EXTSIG
- CENSIG
- ENDSIG
- LOCHDR
- EXTHDR
- CENHDR
- ENDHDR
- LOCVER
- LOCFLG
- LOCHOW
- LOCTIM
- LOCCRC
- LOCSIZ
- LOCLEN
- LOCNAM
- LOCEXT
- EXTCRC
- EXTSIZ
- EXTLEN
- CENVEM
- CENVER
- CENFLG
- CENHOW
- CENTIM
- CENCRC
- CENSIZ
- CENLEN
- CENNAM
- CENEXT
- CENCOM
- CENDSK
- CENATT
- CENATX
- CENOFF
- ENDSUB
- ENDTOT
- ENDSIZ
- ENDOFF
- ENDCOM
- Constructor Detail
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- Method Detail
- getComment
- getEntry
- getInputStream
- getName
- entries
- stream
- size
- close
- finalize
- Class ZipInputStream
- Field Summary
- Fields declared in class java.util.zip.InflaterInputStream
- Fields declared in class java.io.FilterInputStream
- Constructor Summary
- Method Summary
- Methods declared in class java.util.zip.InflaterInputStream
- Methods declared in class java.io.FilterInputStream
- Methods declared in class java.io.InputStream
- Methods declared in class java.lang.Object
- Field Details
- LOCSIG
- EXTSIG
- CENSIG
- ENDSIG
- LOCHDR
- EXTHDR
- CENHDR
- ENDHDR
- LOCVER
- LOCFLG
- LOCHOW
- LOCTIM
- LOCCRC
- LOCSIZ
- LOCLEN
- LOCNAM
- LOCEXT
- EXTCRC
- EXTSIZ
- EXTLEN
- CENVEM
- CENVER
- CENFLG
- CENHOW
- CENTIM
- CENCRC
- CENSIZ
- CENLEN
- CENNAM
- CENEXT
- CENCOM
- CENDSK
- CENATT
- CENATX
- CENOFF
- ENDSUB
- ENDTOT
- ENDSIZ
- ENDOFF
- ENDCOM
- Constructor Details
- ZipInputStream
- ZipInputStream
- Method Details
- getNextEntry
- closeEntry
- available
- read
- skip
- close
- createZipEntry
- Open zip files in java
- Field Summary
- Constructor Summary
- Method Summary
- Methods inherited from class java.lang.Object
- Field Detail
- OPEN_READ
- OPEN_DELETE
- LOCSIG
- EXTSIG
- CENSIG
- ENDSIG
- LOCHDR
- EXTHDR
- CENHDR
- ENDHDR
- LOCVER
- LOCFLG
- LOCHOW
- LOCTIM
- LOCCRC
- LOCSIZ
- LOCLEN
- LOCNAM
- LOCEXT
- EXTCRC
- EXTSIZ
- EXTLEN
- CENVEM
- CENVER
- CENFLG
- CENHOW
- CENTIM
- CENCRC
- CENSIZ
- CENLEN
- CENNAM
- CENEXT
- CENCOM
- CENDSK
- CENATT
- CENATX
- CENOFF
- ENDSUB
- ENDTOT
- ENDSIZ
- ENDOFF
- ENDCOM
- Constructor Detail
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- ZipFile
- Method Detail
- getComment
Open zip files in java
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.
Field Summary
Constructor Summary
Method Summary
Methods declared in class java.lang.Object
Field Detail
OPEN_READ
public static final int OPEN_READ
OPEN_DELETE
public static final int 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.
LOCSIG
public static final long LOCSIG
EXTSIG
public static final long EXTSIG
CENSIG
public static final long CENSIG
ENDSIG
public static final long ENDSIG
LOCHDR
public static final int LOCHDR
EXTHDR
public static final int EXTHDR
CENHDR
public static final int CENHDR
ENDHDR
public static final int ENDHDR
LOCVER
public static final int LOCVER
LOCFLG
public static final int LOCFLG
LOCHOW
public static final int LOCHOW
LOCTIM
public static final int LOCTIM
LOCCRC
public static final int LOCCRC
LOCSIZ
public static final int LOCSIZ
LOCLEN
public static final int LOCLEN
LOCNAM
public static final int LOCNAM
LOCEXT
public static final int LOCEXT
EXTCRC
public static final int EXTCRC
EXTSIZ
public static final int EXTSIZ
EXTLEN
public static final int EXTLEN
CENVEM
public static final int CENVEM
CENVER
public static final int CENVER
CENFLG
public static final int CENFLG
CENHOW
public static final int CENHOW
CENTIM
public static final int CENTIM
CENCRC
public static final int CENCRC
CENSIZ
public static final int CENSIZ
CENLEN
public static final int CENLEN
CENNAM
public static final int CENNAM
CENEXT
public static final int CENEXT
CENCOM
public static final int CENCOM
CENDSK
public static final int CENDSK
CENATT
public static final int CENATT
CENATX
public static final int CENATX
CENOFF
public static final int CENOFF
ENDSUB
public static final int ENDSUB
ENDTOT
public static final int ENDTOT
ENDSIZ
public static final int ENDSIZ
ENDOFF
public static final int ENDOFF
ENDCOM
public static final int ENDCOM
Constructor Detail
ZipFile
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. The UTF-8 charset is used to decode the entry names and comments.
ZipFile
public ZipFile(File file, int mode) throws IOException
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. The UTF-8 charset is used to decode the entry names and comments
ZipFile
public ZipFile(File file) throws ZipException, IOException
Opens a ZIP file for reading given the specified File object. The UTF-8 charset is used to decode the entry names and comments.
ZipFile
public ZipFile(File file, int mode, Charset charset) throws IOException
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.
ZipFile
public ZipFile(String name, Charset charset) throws IOException
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.
ZipFile
public ZipFile(File file, Charset charset) throws IOException
Method Detail
getComment
getEntry
getInputStream
public InputStream getInputStream(ZipEntry entry) throws IOException
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.
getName
entries
stream
Returns an ordered Stream over the ZIP file entries. Entries appear in the Stream in the order they appear in the central directory of the ZIP file.
size
close
Closes the ZIP file. Closing this ZIP file will close all of the input streams previously returned by invocations of the getInputStream method.
finalize
@Deprecated(since="9", forRemoval=true) protected void finalize() throws IOException
The finalize method has been deprecated and will be removed. It is implemented as a no-op. Subclasses that override finalize in order to perform cleanup should be modified to use alternative cleanup mechanisms and to remove the overriding finalize method. The recommended cleanup for ZipFile object is to explicitly invoke close method when it is no longer in use, or use try-with-resources. If the close is not invoked explicitly the resources held by this object will be released when the instance becomes unreachable.
Ensures that the system resources held by this ZipFile object are released when there are no more references to it.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Class ZipInputStream
This class implements an input stream filter for reading files in the ZIP file format. Includes support for both compressed and uncompressed entries.
Field Summary
Fields declared in class java.util.zip.InflaterInputStream
Fields declared in class java.io.FilterInputStream
Constructor Summary
Method Summary
Methods declared in class java.util.zip.InflaterInputStream
Methods declared in class java.io.FilterInputStream
Methods declared in class java.io.InputStream
Methods declared in class java.lang.Object
Field Details
LOCSIG
EXTSIG
CENSIG
ENDSIG
LOCHDR
EXTHDR
CENHDR
ENDHDR
LOCVER
LOCFLG
LOCHOW
LOCTIM
LOCCRC
LOCSIZ
LOCLEN
LOCNAM
LOCEXT
EXTCRC
EXTSIZ
EXTLEN
CENVEM
CENVER
CENFLG
CENHOW
CENTIM
CENCRC
CENSIZ
CENLEN
CENNAM
CENEXT
CENCOM
CENDSK
CENATT
CENATX
CENOFF
ENDSUB
ENDTOT
ENDSIZ
ENDOFF
ENDCOM
Constructor Details
ZipInputStream
ZipInputStream
Method Details
getNextEntry
closeEntry
available
Returns 0 after EOF has reached for the current entry data, otherwise always return 1. Programs should not count on this method to return the actual number of bytes that could be read without blocking.
read
Reads from the current ZIP entry into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.
skip
close
createZipEntry
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Open zip files in java
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.
Field Summary
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 |
Constructor Summary
Method Summary
Ensures that the system resources held by this ZipFile object are released when there are no more references to it.
Methods inherited from class java.lang.Object
Field Detail
OPEN_READ
public static final int OPEN_READ
OPEN_DELETE
public static final int 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.
LOCSIG
public static final long LOCSIG
EXTSIG
public static final long EXTSIG
CENSIG
public static final long CENSIG
ENDSIG
public static final long ENDSIG
LOCHDR
public static final int LOCHDR
EXTHDR
public static final int EXTHDR
CENHDR
public static final int CENHDR
ENDHDR
public static final int ENDHDR
LOCVER
public static final int LOCVER
LOCFLG
public static final int LOCFLG
LOCHOW
public static final int LOCHOW
LOCTIM
public static final int LOCTIM
LOCCRC
public static final int LOCCRC
LOCSIZ
public static final int LOCSIZ
LOCLEN
public static final int LOCLEN
LOCNAM
public static final int LOCNAM
LOCEXT
public static final int LOCEXT
EXTCRC
public static final int EXTCRC
EXTSIZ
public static final int EXTSIZ
EXTLEN
public static final int EXTLEN
CENVEM
public static final int CENVEM
CENVER
public static final int CENVER
CENFLG
public static final int CENFLG
CENHOW
public static final int CENHOW
CENTIM
public static final int CENTIM
CENCRC
public static final int CENCRC
CENSIZ
public static final int CENSIZ
CENLEN
public static final int CENLEN
CENNAM
public static final int CENNAM
CENEXT
public static final int CENEXT
CENCOM
public static final int CENCOM
CENDSK
public static final int CENDSK
CENATT
public static final int CENATT
CENATX
public static final int CENATX
CENOFF
public static final int CENOFF
ENDSUB
public static final int ENDSUB
ENDTOT
public static final int ENDTOT
ENDSIZ
public static final int ENDSIZ
ENDOFF
public static final int ENDOFF
ENDCOM
public static final int ENDCOM
Constructor Detail
ZipFile
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. The UTF-8 charset is used to decode the entry names and comments.
ZipFile
public ZipFile(File file, int mode) throws IOException
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. The UTF-8 charset is used to decode the entry names and comments
ZipFile
public ZipFile(File file) throws ZipException, IOException
Opens a ZIP file for reading given the specified File object. The UTF-8 charset is used to decode the entry names and comments.
ZipFile
public ZipFile(File file, int mode, Charset charset) throws IOException
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.
ZipFile
public ZipFile(String name, Charset charset) throws IOException
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.
ZipFile
public ZipFile(File file, Charset charset) throws IOException