Examples of TarArchiveOutputStream


Examples of com.dotcms.repackage.org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

  {
    Logger.info(PushUtils.class, "Compressing "+files.size() + " to "+output.getAbsoluteFile());
                 // Create the output stream for the output file
    FileOutputStream fos = new FileOutputStream(output);
                 // Wrap the output file stream in streams that will tar and gzip everything
    TarArchiveOutputStream taos = new TarArchiveOutputStream(
      new GZIPOutputStream(new BufferedOutputStream(fos)));

                 // TAR originally didn't support long file names, so enable the support for it
    taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);

                 // Get to putting all the files in the compressed output file
    for (File f : files) {
      addFilesToCompression(taos, f, ".", bundleRoot);
    }

                 // Close everything up
    taos.close();
    fos.close();
    return output;
  }
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

      throws IOException {

    FileOutputStream out = null;
    try {
      out = new FileOutputStream(new File(parentDir, outputFile));
      TarArchiveOutputStream tOut = new TarArchiveOutputStream(
          new GzipCompressorOutputStream(new BufferedOutputStream(out)));

      for (int i = 0; i < inputFiles.length; i++) {
        File f = new File(parentDir, inputFiles[i]);
        TarArchiveEntry tarEntry = new TarArchiveEntry(f, f.getName());
        tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
        tOut.putArchiveEntry(tarEntry);
        FileInputStream input = new FileInputStream(f);
        try {
          IOUtils.copy(input, tOut); // copy with 8K buffer, not close
        } finally {
          input.close();
        }
        tOut.closeArchiveEntry();
      }
      tOut.close(); // finishes inside
    } finally {
      // TarArchiveOutputStream seemed not to close files properly in error situation
      org.apache.hadoop.io.IOUtils.closeStream(out);
    }
  }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

            byte ba_1k[] = new byte[(int) _1K];
            for(int i=0; i < ba_1k.length; i++){
                ba_1k[i]='a';
            }
            try {
                TarArchiveOutputStream outTarStream =
                    (TarArchiveOutputStream)new ArchiveStreamFactory()
                    .createArchiveOutputStream(ArchiveStreamFactory.TAR, outTarFileStream);
                // Create archive contents
                TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(name + ".txt");
                tarArchiveEntry.setSize(fileSize);

                outTarStream.putArchiveEntry(tarArchiveEntry);
                for(long i = 0; i < fileSize; i+= ba_1k.length) {
                    outTarStream.write(ba_1k);
                }
                outTarStream.closeArchiveEntry();
                outTarStream.close();
                outTarFileStream.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

  ** OutputStream os will be close()d if this method returns successfully.
  */
  private String createTarBucket(OutputStream os) throws IOException {
    if(logMINOR) Logger.minor(this, "Create a TAR Bucket");
   
    TarArchiveOutputStream tarOS = new TarArchiveOutputStream(os);
    try {
      tarOS.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
      TarArchiveEntry ze;

      for (ContainerElement ph : containerItems) {
        if (logMINOR)
          Logger.minor(this, "Putting into tar: " + ph + " data length " + ph.data.size() + " name " + ph.targetInArchive);
        ze = new TarArchiveEntry(ph.targetInArchive);
        ze.setModTime(0);
        long size = ph.data.size();
        ze.setSize(size);
        tarOS.putArchiveEntry(ze);
        BucketTools.copyTo(ph.data, tarOS, size);
        tarOS.closeArchiveEntry();
      }
    } finally {
      tarOS.close();
    }
   
    return ARCHIVE_TYPE.TAR.mimeTypes[0];
  }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

   * archive successfully
   */
  public static void generateGZippedTar(final OutputStream outputStream, final File file) throws IOException {
    BufferedOutputStream bOut = null;
    GzipCompressorOutputStream gzOut = null;
    TarArchiveOutputStream tOut = null;
    try {
      bOut = new BufferedOutputStream(outputStream);
      gzOut = new GzipCompressorOutputStream(bOut);
      tOut = new TarArchiveOutputStream(gzOut);
      if (file.isDirectory()) {
        addFileToTar(tOut, file, "/");
      } else {
        addFileToTar(tOut, file, file.getName());
      }
    } finally {
      if (tOut != null) {
        tOut.finish();
        tOut.close();
      }
      if (gzOut != null) {
        gzOut.close();
      }
      if (bOut != null) {
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

    public Tar() {
        setFactory(new TarStreamFactory(){
                public ArchiveOutputStream getArchiveStream(OutputStream stream,
                                                            String encoding)
                    throws IOException {
                    TarArchiveOutputStream o =
                        (TarArchiveOutputStream) super.getArchiveStream(stream,
                                                                        encoding);
                    if (format.equals(Format.OLDGNU)) {
                        o.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                    }
                    else if (format.equals(Format.GNU)) {
                        o.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                        o.setBigNumberMode(TarArchiveOutputStream
                                           .BIGNUMBER_STAR);
                    }
                    else if (format.equals(Format.STAR)) {
                        o.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
                        o.setBigNumberMode(TarArchiveOutputStream
                                           .BIGNUMBER_STAR);
                    }
                    else if (format.equals(Format.PAX)) {
                        o.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
                        o.setBigNumberMode(TarArchiveOutputStream
                                           .BIGNUMBER_POSIX);
                        o.setAddPaxHeadersForNonAsciiNames(true);
                    }
                    return o;
                }
            });
        setEntryBuilder(
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

     * @param encoding the encoding of the entry names
     */
    public ArchiveOutputStream getArchiveStream(OutputStream stream,
                                                String encoding)
        throws IOException {
        return new TarArchiveOutputStream(stream, encoding);
    }
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

    byte[] bytes = new byte[len];
    r.nextBytes(bytes);

    File archiveFile = new File(p.toUri().getPath() + ".tar");
    archiveFile.createNewFile();
    TarArchiveOutputStream out = new TarArchiveOutputStream(
        new FileOutputStream(archiveFile));
    TarArchiveEntry entry = new TarArchiveEntry(p.getName());
    entry.setSize(bytes.length);
    out.putArchiveEntry(entry);
    out.write(bytes);
    out.closeArchiveEntry();
    out.close();

    LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
    ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString()
        + ".tar")));
    ret.setSize(len);
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

    byte[] bytes = new byte[len];
    r.nextBytes(bytes);

    File gzipFile = new File(p.toUri().getPath() + ".tar.gz");
    gzipFile.createNewFile();
    TarArchiveOutputStream out = new TarArchiveOutputStream(
        new GZIPOutputStream(new FileOutputStream(gzipFile)));
    TarArchiveEntry entry = new TarArchiveEntry(p.getName());
    entry.setSize(bytes.length);
    out.putArchiveEntry(entry);
    out.write(bytes);
    out.closeArchiveEntry();
    out.close();

    LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
    ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString()
        + ".tar.gz")));
    ret.setSize(len);
View Full Code Here

Examples of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream

    public Tar() {
        setFactory(new TarStreamFactory(){
                public ArchiveOutputStream getArchiveStream(OutputStream stream,
                                                            String encoding)
                    throws IOException {
                    TarArchiveOutputStream o =
                        (TarArchiveOutputStream) super.getArchiveStream(stream,
                                                                        encoding);
                    if (format.equals(Format.OLDGNU)) {
                        o.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                    }
                    return o;
                }
            });
        setEntryBuilder(
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.