protected void extract()

in src/main/org/apache/ant/compress/taskdefs/UnpackBase.java [95:124]


    protected void extract() {
        if (source.lastModified() > dest.lastModified()) {
            log("Expanding " + source.getAbsolutePath() + " to "
                + dest.getAbsolutePath());

            CompressorInputStream zIn = null;
            InputStream fis = null;
            try (OutputStream out = Files.newOutputStream(dest.toPath())) {
                zIn = StreamHelper.getInputStream(factory, srcResource);
                if (zIn == null) {
                    fis = srcResource.getInputStream();
                    if (factory instanceof CompressorWithConcatenatedStreamsFactory) {
                        CompressorWithConcatenatedStreamsFactory f
                            = (CompressorWithConcatenatedStreamsFactory) factory;
                        zIn = f.getCompressorStream(new BufferedInputStream(fis),
                                                    decompressConcatenated);
                    } else {
                        zIn = factory.getCompressorStream(new BufferedInputStream(fis));
                    }
                }
                IOUtils.copy(zIn, out, BUFFER_SIZE);
            } catch (IOException ioe) {
                String msg = "Problem expanding " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
                FileUtils.close(fis);
                FileUtils.close(zIn);
            }
        }
    }