IT. Expert System.

Android Reference

ZipInputStream


java.util.zip

Class ZipInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    JarInputStream


    public class ZipInputStream
    extends InflaterInputStream
    This class provides an implementation of FilterInputStream that decompresses data from an InputStream containing a ZIP archive.

    A ZIP archive is a collection of (possibly) compressed files. When reading from a ZipInputStream, you retrieve the entry's metadata with getNextEntry before you can read the userdata.

    Although InflaterInputStream can only read compressed ZIP archive entries, this class can read non-compressed entries as well.

    Use ZipFile if you can access the archive as a file directly, especially if you want random access to entries, rather than needing to iterate over all entries.

    Example

    Using ZipInputStream is a little more complicated than GZIPInputStream because ZIP archives are containers that can contain multiple files. This code pulls all the files out of a ZIP archive, similar to the unzip(1) utility.

     InputStream is = ...
     ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
     try {
         ZipEntry ze;
         while ((ze = zis.getNextEntry()) != null) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             byte[] buffer = new byte[1024];
             int count;
             while ((count = zis.read(buffer)) != -1) {
                 baos.write(buffer, 0, count);
             }
             String filename = ze.getName();
             byte[] bytes = baos.toByteArray();
             // do something with 'filename' and 'bytes'...
         }
     } finally {
         zis.close();
     }
     
    See Also:
    ZipEntry, ZipFile


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 16496 / 248377140. Delta: 0.03205 с