Package org.xeustechnologies.jtar

Examples of org.xeustechnologies.jtar.TarOutputStream


        try {
            // Output file stream
            FileOutputStream dest = new FileOutputStream(targetFolderStr + "inputs.tar");

            // Create a TarOutputStream
            TarOutputStream out = new TarOutputStream(new BufferedOutputStream(dest));

            // Files to tar
            for (File f : content) {

                try {
                    out.putNextEntry(new TarEntry(f, f.getName()));
                    BufferedInputStream origin = new BufferedInputStream(new FileInputStream(f));

                    int count;
                    byte data[] = new byte[2048];
                    while ((count = origin.read(data)) != -1) {
                        out.write(data, 0, count);
                    }

                    out.flush();
                    origin.close();

                } catch (IOException ex) {
                    Logger.getLogger(CompressUtil.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            out.close();
            return new File(targetFolderStr + "inputs.tar");

        } catch (IOException ex) {
            logger.warn(ex.getLocalizedMessage());
        }
View Full Code Here

TOP

Related Classes of org.xeustechnologies.jtar.TarOutputStream

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.