Class ZipInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ZipInputStream
    extends java.io.InputStream
    • Field Detail

      • inputStream

        private java.io.PushbackInputStream inputStream
      • password

        private char[] password
      • crc32

        private java.util.zip.CRC32 crc32
      • endOfEntryBuffer

        private byte[] endOfEntryBuffer
      • canSkipExtendedLocalFileHeader

        private boolean canSkipExtendedLocalFileHeader
      • streamClosed

        private boolean streamClosed
      • entryEOFReached

        private boolean entryEOFReached
    • Constructor Detail

      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              java.nio.charset.Charset charset)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              char[] password)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              PasswordCallback passwordCallback)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              char[] password,
                              java.nio.charset.Charset charset)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              PasswordCallback passwordCallback,
                              java.nio.charset.Charset charset)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              char[] password,
                              Zip4jConfig zip4jConfig)
      • ZipInputStream

        public ZipInputStream​(java.io.InputStream inputStream,
                              PasswordCallback passwordCallback,
                              Zip4jConfig zip4jConfig)
      • ZipInputStream

        private ZipInputStream​(java.io.InputStream inputStream,
                               char[] password,
                               PasswordCallback passwordCallback,
                               Zip4jConfig zip4jConfig)
    • Method Detail

      • getNextEntry

        public LocalFileHeader getNextEntry()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getNextEntry

        public LocalFileHeader getNextEntry​(FileHeader fileHeader,
                                            boolean readUntilEndOfCurrentEntryIfOpen)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • setPassword

        public void setPassword​(char[] password)
        Sets the password for the inputstream. This password will be used for any subsequent encrypted entries that will be read from this stream. If this method is called when an entry is being read, it has no effect on the read action of the current entry, and the password will take effect from any subsequent entry reads.
        Parameters:
        password - Password to be used for reading of entries from the zip input stream
      • endOfCompressedDataReached

        private void endOfCompressedDataReached()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readExtendedLocalFileHeaderIfPresent

        private void readExtendedLocalFileHeaderIfPresent()
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • verifyLocalFileHeader

        private void verifyLocalFileHeader​(LocalFileHeader localFileHeader)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • checkIfZip64ExtraDataRecordPresentInLFH

        private boolean checkIfZip64ExtraDataRecordPresentInLFH​(java.util.List<ExtraDataRecord> extraDataRecords)
      • verifyCrc

        private void verifyCrc()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • resetFields

        private void resetFields()
      • isEntryDirectory

        private boolean isEntryDirectory​(java.lang.String entryName)
      • readUntilEndOfEntry

        private void readUntilEndOfEntry()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • isEncryptionMethodZipStandard

        private boolean isEncryptionMethodZipStandard​(LocalFileHeader localFileHeader)
      • assertStreamOpen

        private void assertStreamOpen()
                               throws java.io.IOException
        Throws:
        java.io.IOException