Examples of GzipCompressorInputStream


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

                try {
                    fin = new FileInputStream(flashPlayerBinary);
                    final BufferedInputStream in = new BufferedInputStream(fin);
                    final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
                    final FileOutputStream out = new FileOutputStream(tempTarFile);
                    final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
                    final byte[] buffer = new byte[1024];
                    int n;
                    while (-1 != (n = gzIn.read(buffer))) {
                        out.write(buffer, 0, n);
                    }
                    out.close();
                    gzIn.close();

                    // Then untar it.
                    File uncompressedBinary = null;
                    final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
                    final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
View Full Code Here

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

   */
  public static File ungzip(final File inFile, final File outFile) {
    FileInputStream fin = null;
    BufferedInputStream in = null;
    FileOutputStream fout = null;
    GzipCompressorInputStream gzIn = null;
    try {
      fin = new FileInputStream(inFile);
      in = new BufferedInputStream(fin);
      gzIn = new GzipCompressorInputStream(in);
      if (!outFile.getParentFile().exists()) {
        outFile.getParentFile().mkdirs();
      }
      fout = new FileOutputStream(outFile);
      final byte[] buffer = new byte[4048];
      int n;
      while (-1 != (n = gzIn.read(buffer))) {
        fout.write(buffer, 0, n);
      }
    } catch (Exception e) {
      throw processException("Error while ungzip file", e);
    } finally {
View Full Code Here

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

public class ChainingTestCase extends AbstractTestCase {

    public void testTarGzip() throws Exception {
        File file = new File("src/test/resources/bla.tgz");
        final TarArchiveInputStream is = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(file)));
        final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
        assertNotNull(entry);
        assertEquals("test1.xml", entry.getName());
        is.close();
    }
View Full Code Here

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

        InputStream in;
        InputStream fin = new BufferedInputStream(new FileInputStream(file));
        try {
            if(compression != null) {
                if (CompressorStreamFactory.GZIP.equalsIgnoreCase(compression)) {
                    in = new GzipCompressorInputStream(fin,true);
                } else if (CompressorStreamFactory.BZIP2.equalsIgnoreCase(compression)) {
                    in = new BZip2CompressorInputStream(fin, true);
                } else {
                    // does not honour decompressConcatenated
                    in = cf.createCompressorInputStream(compression, fin);
View Full Code Here

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

                String archiveCompression = detectCompression(archive);
                InputStream fin = new BufferedInputStream(new FileInputStream(archive));
                if(archiveCompression != null) {
                    if (CompressorStreamFactory.GZIP.equalsIgnoreCase(archiveCompression)) {
                        log.info("auto-detected archive compression: GZIP");
                        in = new GzipCompressorInputStream(fin,true);
                    } else if (CompressorStreamFactory.BZIP2.equalsIgnoreCase(archiveCompression)) {
                        log.info("auto-detected archive compression: BZIP2");
                        in = new BZip2CompressorInputStream(fin, true);
                    } else {
                        in = fin;
View Full Code Here

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

      ArchiveInputStream input;
   
            /* I am really sad that classes aren't first-class objects in
               Java :'( */
      try {
        input = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(file)));
      } catch (IOException e) {
        try {
          input = new TarArchiveInputStream(new BZip2CompressorInputStream(new FileInputStream(file)));
        } catch (IOException e2) {
          input = new ZipArchiveInputStream(new FileInputStream(file));
View Full Code Here

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

            if (BZip2CompressorInputStream.matches(signature, signatureLength)) {
                return new BZip2CompressorInputStream(in);
            }

            if (GzipCompressorInputStream.matches(signature, signatureLength)) {
                return new GzipCompressorInputStream(in);
            }

            if (XZCompressorInputStream.matches(signature, signatureLength)) {
                return new XZCompressorInputStream(in);
            }
View Full Code Here

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

        }

        try {

            if (GZIP.equalsIgnoreCase(name)) {
                return new GzipCompressorInputStream(in);
            }

            if (BZIP2.equalsIgnoreCase(name)) {
                return new BZip2CompressorInputStream(in);
            }
View Full Code Here

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

    public void testConcatenatedStreamsReadFully() throws Exception {
        final File input = getFile("multiple.gz");
        final InputStream is = new FileInputStream(input);
        try {
            final CompressorInputStream in =
                new GzipCompressorInputStream(is, true);
            try {
                assertEquals('a', in.read());
                assertEquals('b', in.read());
                assertEquals(0, in.available());
                assertEquals(-1, in.read());
            } finally {
                in.close();
            }
        } finally {
            is.close();
        }
    }
View Full Code Here

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

      s = s.substring(0, s.lastIndexOf("."));
    }
   
    try
    {
      org.apache.commons.compress.utils.IOUtils.copy(new GzipCompressorInputStream(new FileInputStream(archive)), new FileOutputStream(new File(s)));
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
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.