Esempio n. 1
0
        /*
         * Returns an input stream on the data of the specified {@code ZipEntry}.
         *
         * @param entry
         *            the ZipEntry.
         * @return an input stream of the data contained in the {@code ZipEntry}.
         * @throws IOException
         *             if an {@code IOException} occurs.
         * @throws IllegalStateException if this ZIP file has been closed.
         */
        public java.io.InputStream getInputStream(ZipEntry entry) // throws IOException {

        /*
         * Make sure this ZipEntry is in this Zip file.  We run it through
         * the name lookup.
         */
        {
            entry = getEntry(entry.getName());
            if (entry == null)
            {
                return(null);
            }

            /*
             * Create a ZipInputStream at the right part of the file.
             */
            java.io.RandomAccessFile raf = mRaf;
            lock (raf) {
                // We don't know the entry data's start position. All we have is the
                // position of the entry's local header. At position 28 we find the
                // length of the extra data. In some cases this length differs from
                // the one coming in the central header.
                RAFStream rafstrm = new RAFStream(raf,
                                                  entry.mLocalHeaderRelOffset + 28);
                int localExtraLenOrWhatever = ler.readShortLE(rafstrm);
                // Skip the name and this "extra" data or whatever it is:
                rafstrm.skip(entry.nameLen + localExtraLenOrWhatever);
                rafstrm.mLength = rafstrm.mOffset + entry.compressedSize;
                if (entry.compressionMethod == ZipEntry.DEFLATED)
                {
                    int bufSize = java.lang.Math.max(1024, (int)java.lang.Math.min(entry.getSize(), 65535L));
                    return(new ZipInflaterInputStream(rafstrm, new Inflater(true), bufSize, entry));
                }
                else
                {
                    return(rafstrm);
                }
            }
        }
Esempio n. 2
0
 public override int available()  //throws IOException {
 {
     return(base.available() == 0 ? 0 : (int)(entry.getSize() - bytesRead));
 }