public void unpack()

in src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java [188:255]


    public void unpack() throws Pack200Exception, IOException {
        outputStream.setComment("PACK200");
        try {
            if (!inputStream.markSupported()) {
                inputStream = new BoundedInputStream(new BufferedInputStream(inputStream));
                if (!inputStream.markSupported()) {
                    throw new IllegalStateException();
                }
            }
            inputStream.mark(2);
            if ((inputStream.read() & 0xFF | (inputStream.read() & 0xFF) << 8) == GZIPInputStream.GZIP_MAGIC) {
                inputStream.reset();
                inputStream = new BoundedInputStream(new BufferedInputStream(new GZIPInputStream(inputStream)));
            } else {
                inputStream.reset();
            }
            inputStream.mark(MAGIC.length);
            // pack200
            final int[] word = new int[MAGIC.length];
            for (int i = 0; i < word.length; i++) {
                word[i] = inputStream.read();
            }
            boolean compressedWithE0 = false;
            for (int m = 0; m < MAGIC.length; m++) {
                if (word[m] != MAGIC[m]) {
                    compressedWithE0 = true;
                    break;
                }
            }
            inputStream.reset();
            if (compressedWithE0) { // The original Jar was not packed, so just copy it across.
                final JarInputStream jarInputStream = new JarInputStream(inputStream);
                JarEntry jarEntry;
                while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
                    outputStream.putNextEntry(jarEntry);
                    IOUtils.copy(jarInputStream, outputStream, 16_384);
                    outputStream.closeEntry();
                }
            } else {
                int i = 0;
                while (available(inputStream)) {
                    i++;
                    final Segment segment = new Segment();
                    segment.setLogLevel(logLevel);
                    segment.setLogStream(logFile);
                    segment.setPreRead(false);
                    if (i == 1) {
                        segment.log(Segment.LOG_LEVEL_VERBOSE, "Unpacking from " + inputPath + " to " + outputFileName);
                    }
                    segment.log(Segment.LOG_LEVEL_VERBOSE, "Reading segment " + i);
                    if (overrideDeflateHint) {
                        segment.overrideDeflateHint(deflateHint);
                    }
                    segment.unpack(inputStream, outputStream);
                    outputStream.flush();
                }
            }
        } finally {
            if (closeStreams) {
                IOUtils.closeQuietly(inputStream);
                IOUtils.closeQuietly(outputStream);
            }
            IOUtils.closeQuietly(logFile);
        }
        if (removePackFile && inputPath != null) {
            Files.delete(inputPath);
        }
    }