Examples of GzipCompressorOutputStream


Examples of com.facebook.presto.hive.shaded.org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

    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);
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

      source.start();

      // Create compressed archive
      OutputStream outGzipFileStream = new FileOutputStream(path + name + ".tar.gz");

      GzipCompressorOutputStream outGzipStream = (GzipCompressorOutputStream)new CompressorStreamFactory()
      .createCompressorOutputStream(CompressorStreamFactory.GZIP, outGzipFileStream);

      IOUtils.copy(inTarFileStream, outGzipStream);
      inTarFileStream.close();

      outGzipStream.close();
      outGzipFileStream.close();

    }
  }
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

   * @throws IOException - in case we cannot read a file or generate the
   * 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) {
        bOut.close();
      }
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

    /**
     * @param stream the stream to write to, should be buffered
     */
    public CompressorOutputStream getCompressorStream(OutputStream stream)
        throws IOException {
        return new GzipCompressorOutputStream(stream);
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

   * @throws IOException when an exception occurs on creating the tarball
   */
  public static void createFromDirectory(String sourceDirectory, String targetName) throws IOException {
    FileOutputStream fileOutputStream = null;
    BufferedOutputStream bufferedOutputStream = null;
    GzipCompressorOutputStream gzipOutputStream = null;
    TarArchiveOutputStream tarArchiveOutputStream = null;

    try {
      fileOutputStream = new FileOutputStream(new File(targetName));
      bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
      gzipOutputStream = new GzipCompressorOutputStream(bufferedOutputStream);
      tarArchiveOutputStream = new TarArchiveOutputStream(gzipOutputStream);

      addFilesInDirectory(tarArchiveOutputStream, sourceDirectory);
    } finally {
      if (tarArchiveOutputStream != null) {
        tarArchiveOutputStream.finish();
      }
      if (tarArchiveOutputStream != null) {
        tarArchiveOutputStream.close();
      }
      if (gzipOutputStream != null) {
        gzipOutputStream.close();
      }
      if (bufferedOutputStream != null) {
        bufferedOutputStream.close();
      }
      if (fileOutputStream != null) {
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

        parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
        parameters.setOperatingSystem(3);
        parameters.setFilename("test3.xml");
        parameters.setComment("Test file");
        parameters.setModificationTime(System.currentTimeMillis());
        GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters);
        out.write(content);
        out.flush();
        out.close();

        GzipCompressorInputStream in = new GzipCompressorInputStream(new ByteArrayInputStream(bout.toByteArray()));
        byte[] content2 = IOUtils.toByteArray(in);

        Assert.assertArrayEquals("uncompressed content", content, content2);
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

        parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
        parameters.setOperatingSystem(3);
        parameters.setFilename("test3.xml");
        parameters.setComment("Test file");
        parameters.setModificationTime(System.currentTimeMillis());
        GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters);
        out.write(content);
        out.flush();
        out.close();

        GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(bout.toByteArray()));
        byte[] content2 = IOUtils.toByteArray(in);

        Assert.assertArrayEquals("uncompressed content", content, content2);
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

       
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
       
        GzipParameters parameters = new GzipParameters();
        parameters.setCompressionLevel(compressionLevel);
        GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters);
        IOUtils.copy(new ByteArrayInputStream(content), out);
        out.flush();
        out.close();
       
        assertEquals("extra flags (XFL)", flag, bout.toByteArray()[8]);
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

    public void testExtraFlagsDefaultCompression() throws Exception {
        testExtraFlags(Deflater.DEFAULT_COMPRESSION, 0);
    }
   
    public void testOverWrite() throws Exception {
        GzipCompressorOutputStream out = new GzipCompressorOutputStream(new ByteArrayOutputStream());
        out.close();
        try {
            out.write(0);
            fail("IOException expected");
        } catch (IOException e) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

        parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
        parameters.setModificationTime(123456000);
        parameters.setOperatingSystem(13);
        parameters.setFilename("test3.xml");
        parameters.setComment("Umlaute möglich?");
        GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters);
        FileInputStream fis = new FileInputStream(getFile("test3.xml"));
        try {
            IOUtils.copy(fis, out);
        } finally {
            fis.close();
            out.close();
        }
       
        GzipCompressorInputStream input =
            new GzipCompressorInputStream(new ByteArrayInputStream(bout.toByteArray()));
        input.close();
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.