Examples of GzipCompressorInputStream


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

        }

        try {

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

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

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

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

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

            if (XZUtils.isXZCompressionAvailable() &&
                XZCompressorInputStream.matches(signature, signatureLength)) {
                return new XZCompressorInputStream(in, decompressConcatenated);
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

    }

    private void extractGzArchive(InputStream tarGz, File tar) throws IOException {
        BufferedInputStream in = new BufferedInputStream(tarGz);
        FileOutputStream out = new FileOutputStream(tar);
        GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
        final byte[] buffer = new byte[1000];
        int n = 0;
        while (-1 != (n = gzIn.read(buffer))) {
            out.write(buffer, 0, n);
        }
        out.close();
        gzIn.close();
    }
View Full Code Here

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

                }
                in.close();
            }
            final FileInputStream isGz = new FileInputStream(getFile("lorem-ipsum.txt.gz"));
            try {
                in = new GzipCompressorInputStream(isGz);
                try {
                    out = new FileOutputStream(outputGz);
                    IOUtils.copy(in, out);
                } finally {
                    if (out != null) {
View Full Code Here

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

    }

    @Test
    public void readFileHeadersOfArchiveBiggerThan8GByte() throws Exception {
        InputStream in = null;
        GzipCompressorInputStream gzin = null;
        TarArchiveInputStream tin = null;
        try {
            in = new BufferedInputStream(BigFilesIT.class
                                         .getResourceAsStream("/8.posix.tar.gz")
                                         );
            gzin = new GzipCompressorInputStream(in);
            tin = new TarArchiveInputStream(gzin);
            TarArchiveEntry e = tin.getNextTarEntry();
            assertNotNull(e);
            assertNull(tin.getNextTarEntry());
        } finally {
            if (tin != null) {
                tin.close();
            }
            if (gzin != null) {
                gzin.close();
            }
            if (in != null) {
                in.close();
            }
        }
View Full Code Here

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

        }
    }

    private void readFileBiggerThan8GByte(String name) throws Exception {
        InputStream in = null;
        GzipCompressorInputStream gzin = null;
        TarArchiveInputStream tin = null;
        try {
            in = new BufferedInputStream(BigFilesIT.class
                                         .getResourceAsStream(name));
            gzin = new GzipCompressorInputStream(in);
            tin = new TarArchiveInputStream(gzin);
            TarArchiveEntry e = tin.getNextTarEntry();
            assertNotNull(e);
            assertEquals(8200l * 1024 * 1024, e.getSize());

            long read = 0;
            Random r = new Random(System.currentTimeMillis());
            int readNow;
            byte[] buf = new byte[1024 * 1024];
            while ((readNow = tin.read(buf, 0, buf.length)) > 0) {
                // testing all bytes for a value of 0 is going to take
                // too long, just pick a few ones randomly
                for (int i = 0; i < 100; i++) {
                    int idx = r.nextInt(readNow);
                    assertEquals("testing byte " + (read + idx), 0, buf[idx]);
                }
                read += readNow;
            }
            assertEquals(8200l * 1024 * 1024, read);
            assertNull(tin.getNextTarEntry());
        } finally {
            if (tin != null) {
                tin.close();
            }
            if (gzin != null) {
                gzin.close();
            }
            if (in != null) {
                in.close();
            }
        }
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 = getFile("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

    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

        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
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.