Examples of TarOutputStream


Examples of org.apache.tools.tar.TarOutputStream

                return;
            }

            log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO);

            TarOutputStream tOut = null;
            try {
                tOut = new TarOutputStream(
                    compression.compress(
                        new BufferedOutputStream(
                            new FileOutputStream(tarFile))));
                tOut.setDebug(true);
                if (longFileMode.isTruncateMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
                } else if (longFileMode.isFailMode() ||
                         longFileMode.isOmitMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
                } else {
                    // warn or GNU
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                }

                longWarningGiven = false;
                for (Enumeration e = filesets.elements();
                     e.hasMoreElements();) {
                    TarFileSet fs = (TarFileSet) e.nextElement();
                    String[] files = fs.getFiles(getProject());
                    if (files.length > 1 && fs.getFullpath().length() > 0) {
                        throw new BuildException("fullpath attribute may only "
                                                 + "be specified for "
                                                 + "filesets that specify a "
                                                 + "single file.");
                    }
                    for (int i = 0; i < files.length; i++) {
                        File f = new File(fs.getDir(getProject()), files[i]);
                        String name = files[i].replace(File.separatorChar, '/');
                        tarFile(f, tOut, name, fs);
                    }
                }
            } catch (IOException ioe) {
                String msg = "Problem creating TAR: " + ioe.getMessage();
                throw new BuildException(msg, ioe, location);
            } finally {
                if (tOut != null) {
                    try {
                        // close up
                        tOut.close();
                    } catch (IOException e) {}
                }
            }
        } finally {
            filesets = savedFileSets;
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

                return;
            }

            log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO);

            TarOutputStream tOut = null;
            try {
                tOut = new TarOutputStream(
                    compression.compress(
                        new BufferedOutputStream(
                            new FileOutputStream(tarFile))));
                tOut.setDebug(true);
                if (longFileMode.isTruncateMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
                } else if (longFileMode.isFailMode()
                            || longFileMode.isOmitMode()) {
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
                } else {
                    // warn or GNU
                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                }

                longWarningGiven = false;
                for (Enumeration e = filesets.elements();
                     e.hasMoreElements();) {
                    TarFileSet fs = (TarFileSet) e.nextElement();
                    String[] files = fs.getFiles(getProject());
                    if (files.length > 1 && fs.getFullpath().length() > 0) {
                        throw new BuildException("fullpath attribute may only "
                                                 + "be specified for "
                                                 + "filesets that specify a "
                                                 + "single file.");
                    }
                    for (int i = 0; i < files.length; i++) {
                        File f = new File(fs.getDir(getProject()), files[i]);
                        String name = files[i].replace(File.separatorChar, '/');
                        tarFile(f, tOut, name, fs);
                    }
                }
            } catch (IOException ioe) {
                String msg = "Problem creating TAR: " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
                if (tOut != null) {
                    try {
                        // close up
                        tOut.close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
            }
View Full Code Here

Examples of org.apache.tools.tar.TarOutputStream

        }

        IoActions.withResource(outStr, new ErroringAction<OutputStream>() {
            @Override
            protected void doExecute(final OutputStream outStr) throws Exception {
                TarOutputStream tarOutStr;
                try {
                    tarOutStr = new TarOutputStream(outStr);
                } catch (Exception e) {
                    throw new GradleException(String.format("Could not create TAR '%s'.", tarFile), e);
                }
                tarOutStr.setLongFileMode(TarOutputStream.LONGFILE_GNU);
                stream.process(new StreamAction(tarOutStr));
                tarOutStr.close();
            }
        });

        return new SimpleWorkResult(true);
    }
View Full Code Here

Examples of org.eclipse.php.internal.core.tar.TarOutputStream

      // i do not know why
      os = new CBZip2OutputStreamForPhar(os);
    } else if (PharConstants.GZ_COMPRESSED == pharPackage.getCompressType()) {
      os = new GZIPOutputStream(os);
    }
    outputStream = new TarOutputStream(os);
  }
View Full Code Here

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
Copyright © 2018 www.massapi.com. 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.