Package com.dotcms.repackage.org.apache.commons.compress.compressors.bzip2

Examples of com.dotcms.repackage.org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream


  @Override
  public byte[] inflate(InputStream data) throws CompressionException
  {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    BZip2CompressorInputStream bzip2 = null;

    try
    {
      bzip2 = new BZip2CompressorInputStream(data);
      IOUtils.copy(bzip2, out);
    }
    catch (IOException e)
    {
      throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e);
View Full Code Here


               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

        // Stream buffer
        final int BUFF_SIZE = 8192;
        final byte[] buffer = new byte[BUFF_SIZE];

        BZip2CompressorInputStream inputStream = null;
        FileOutputStream outStream = null;

        try {
            FileInputStream is = new FileInputStream(in.getPath());
            inputStream = new BZip2CompressorInputStream(is);
            outStream = new FileOutputStream(out.getAbsolutePath());

            if (isTar) {
                // Read Tar header
                int remainingBytes = readTarHeader(inputStream);

                // Read content
                ByteBuffer bb = ByteBuffer.allocateDirect(4 * BUFF_SIZE);
                byte[] tmpCache = new byte[BUFF_SIZE];
                int nRead, nGet;
                while ((nRead = inputStream.read(tmpCache)) != -1) {
                    if (nRead == 0) {
                        continue;
                    }
                    bb.put(tmpCache);
                    bb.position(0);
                    bb.limit(nRead);
                    while (bb.hasRemaining() && remainingBytes > 0) {
                        nGet = Math.min(bb.remaining(), BUFF_SIZE);
                        nGet = Math.min(nGet, remainingBytes);
                        bb.get(buffer, 0, nGet);
                        outStream.write(buffer, 0, nGet);
                        remainingBytes -= nGet;
                    }
                    bb.clear();
                }
            } else {
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outStream.write(buffer, 0, len);
                }
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
            if (outStream != null) {
                outStream.close();
            }
        }
View Full Code Here

        try {
            int signatureLength = in.read(signature);
            in.reset();
           
            if (BZip2CompressorInputStream.matches(signature, signatureLength)) {
                return new BZip2CompressorInputStream(in);
            }
           
            if (GzipCompressorInputStream.matches(signature, signatureLength)) {
                return new GzipCompressorInputStream(in);
            }
View Full Code Here

            if (GZIP.equalsIgnoreCase(name)) {
                return new GzipCompressorInputStream(in);
            }
           
            if (BZIP2.equalsIgnoreCase(name)) {
                return new BZip2CompressorInputStream(in);
            }
           
        } catch (IOException e) {
            throw new CompressorException(
                    "Could not create CompressorInputStream.", e);
View Full Code Here

            OpenStreetMapParser parser = new OpenStreetMapParser();
            if (_path.getName().endsWith(".gz")) {
                InputStream in = new GZIPInputStream(new FileInputStream(_path));
                parser.parseMap(in, handler);
            } else if (_path.getName().endsWith(".bz2")) {
                BZip2CompressorInputStream in = new BZip2CompressorInputStream(new FileInputStream(_path));
                parser.parseMap(in, handler);
            } else {
                parser.parseMap(_path, handler);
            }
        } catch (Exception ex) {
View Full Code Here

                in = new GZIPInputStream(new FileInputStream(_path));
                StreamedOpenStreetMapParser.parseMap(in, handler, 3);
                handler.doneThirdPhaseNodes();

            } else if (_path.getName().endsWith(".bz2")) {
                InputStream in = new BZip2CompressorInputStream(new FileInputStream(_path));
                StreamedOpenStreetMapParser.parseMap(in, handler, 1);
                handler.doneFirstPhaseRelations();

                in = new BZip2CompressorInputStream(new FileInputStream(_path));
                StreamedOpenStreetMapParser.parseMap(in, handler, 2);
                handler.doneSecondPhaseWays();

                in = new BZip2CompressorInputStream(new FileInputStream(_path));
                StreamedOpenStreetMapParser.parseMap(in, handler, 3);
                handler.doneThirdPhaseNodes();

            } else {
                StreamedOpenStreetMapParser.parseMap(_path, handler);
View Full Code Here

            throw new CompressException("bzip_compress_error", e);
        }
    }

    public void decompressTo(InputStream in, OutputStream out) throws CompressException {
        BZip2CompressorInputStream inputStream = null;
        try {
            inputStream = new BZip2CompressorInputStream(in);
            NioUtils.copy(inputStream, out);
        } catch (Exception e) {
            throw new CompressException("bzip_decompress_error", e);
        }
    }
View Full Code Here

                                if (uri.endsWith(".gz") || uri.endsWith(".tgz")) {
                                    fis = new GZIPInputStream(fis);
                                } else if (uri.endsWith(".tbz")
                                        || uri.endsWith(".tbz2")
                                        || uri.endsWith(".bzip2")) {
                                    fis = new BZip2CompressorInputStream(fis);
                                }
                                ArchiveInputStream input = new ArchiveStreamFactory()
                                        .createArchiveInputStream(new BufferedInputStream(
                                                fis));
                                ArchiveEntry entry = null;
View Full Code Here

            ais = new ZipArchiveInputStream(is);
        } else {
            if ("gz".equals(archiveFormat)) {
                is = new GZIPInputStream(is);
            } else if ("bz2".equals(archiveFormat)) {
                is = new BZip2CompressorInputStream(is);
            } else {
                throw new IllegalStateException("Unsupported compression format " + archiveFormat + "!. "
                                                + "Please report this to stanbol-dev mailing list!");
            }
            ais = new TarArchiveInputStream(is);
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

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