Package org.codehaus.plexus.archiver.tar

Examples of org.codehaus.plexus.archiver.tar.TarInputStream


    private TarUtil() {
    }

    public static void untar(File source, File target, Log logger) {
        TarInputStream tarInput = null;
        TarEntry entry;
        OutputStream output = null;

        try {
            tarInput = new TarInputStream(new FileInputStream(source));

            entry = tarInput.getNextEntry();
            while (entry != null) {
                File outputFile = new File(target.getCanonicalPath() + File.separator + entry.getName());
                if (entry.isDirectory()) {
                    logger.debug("creating dir at: " + outputFile.getCanonicalPath());
                    outputFile.mkdirs();
                } else {
                    logger.debug("creating file at: " + outputFile.getCanonicalPath());
                    output = new FileOutputStream(outputFile);
                    IOUtils.copy(tarInput, output);
                    output.flush();
                    output.close();
                }

                entry = tarInput.getNextEntry();
            }
        } catch (IOException exception) {
            throw new IllegalStateException(exception);
        } finally {
            IOUtils.closeQuietly(tarInput);
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.tar.TarInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.