Examples of BZip2CompressorInputStream


Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

      // Set a memory limit of 64mb, if this is not sufficient, it will throw
      // an exception rather than an OutOfMemoryError, which will terminate the JVM
      return new XZInputStream(new FileInputStream(file), 64 * 1024 * 1024);
     
    } else if (b1 == 'B' && b2 == 'Z' && b3 == 'h' ) {
      return new BZip2CompressorInputStream(new FileInputStream(file));
   
    } else {
      return new FileInputStream(file);
    }
  }
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

     * @since Apache Compress Antlib 1.2
     */
    public CompressorInputStream getCompressorStream(InputStream stream,
                                                     boolean decompressConcatenated)
        throws IOException {
        return new BZip2CompressorInputStream(stream, decompressConcatenated);
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

      }
   }

   private Bucket uncompress(Blob blob, String bucketName, InputStream content) throws IOException, CacheLoaderException, ClassNotFoundException {
      //TODO go back to fully streamed version and get rid of the byte buffers
      BZip2CompressorInputStream is;
      Bucket bucket;
      ByteArrayOutputStream bos = new ByteArrayOutputStream();

      Streams.copy(content, bos);
      final byte[] compressedByteArray = bos.toByteArray();

      ByteArrayInputStream bis = new ByteArrayInputStream(compressedByteArray);

      is = new BZip2CompressorInputStream(bis);
      ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
      Streams.copy(is, bos2);
      final byte[] uncompressedByteArray = bos2.toByteArray();

      byte[] md5FromStoredBlob = blob.getMetadata().getContentMetadata().getContentMD5();

      // not all blobstores support md5 on GET request
      if (md5FromStoredBlob != null){
         byte[] hash = getMd5Digest(compressedByteArray);
         if (!Arrays.equals(hash, md5FromStoredBlob)) {
            throw new CacheLoaderException("MD5 hash failed when reading (transfer error) for entry " + bucketName);
         }
      }

      is.close();
      bis.close();
      bos.close();
      bos2.close();

      bucket = (Bucket) marshaller
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

        xhtml.startDocument();

        // At the end we want to close the bzip2 stream to release any associated
        // resources, but the underlying document stream should not be closed
        InputStream bzip2 =
            new BZip2CompressorInputStream(new CloseShieldInputStream(stream));
        try {
            Metadata entrydata = new Metadata();
            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
            if (name != null) {
                if (name.endsWith(".tbz")) {
                    name = name.substring(0, name.length() - 4) + ".tar";
                } else if (name.endsWith(".tbz2")) {
                    name = name.substring(0, name.length() - 5) + ".tar";
                } else if (name.endsWith(".bz")) {
                    name = name.substring(0, name.length() - 3);
                } else if (name.endsWith(".bz2")) {
                    name = name.substring(0, name.length() - 4);
                }
                entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
            }
            // Use the delegate parser to parse the compressed document
            super.parse(
                    new CloseShieldInputStream(bzip2),
                    new EmbeddedContentHandler(
                            new BodyContentHandler(xhtml)),
                    entrydata, context);
        } finally {
            bzip2.close();
        }

        xhtml.endDocument();
    }
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

        stream.reset();

        // Select decompression or unpacking mechanism based on the two bytes
        if (a == 'B' && b == 'Z') {
            metadata.set(Metadata.CONTENT_TYPE, "application/x-bzip");
            decompress(new BZip2CompressorInputStream(stream), xhtml);
        } else if (a == 0x1f && b == 0x8b) {
            metadata.set(Metadata.CONTENT_TYPE, "application/x-gzip");
            decompress(new GZIPInputStream(stream), xhtml);
        } else if (a == 'P' && b == 'K') {
            metadata.set(Metadata.CONTENT_TYPE, "application/zip");
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

      br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(wikiDumpFilename)), "UTF-8"));

    } else if (wikiDumpFilename.endsWith(".bz2")) {
      FileInputStream fis = new FileInputStream(wikiDumpFilename);
      br = new BufferedReader(new InputStreamReader(new BZip2CompressorInputStream(fis), "UTF-8"));
    } else {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(wikiDumpFilename), "UTF-8"));
    }

    return br;
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

      br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(wikiDumpFilename)), "UTF-8"));

    } else if (wikiDumpFilename.endsWith(".bz2")) {
      FileInputStream fis = new FileInputStream(wikiDumpFilename);
      br = new BufferedReader(new InputStreamReader(new BZip2CompressorInputStream(fis, true), "UTF-8"));
    } else {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(wikiDumpFilename), "UTF-8"));
    }

    return br;
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

        }

        @Override
        InputStream decode(final InputStream in, final Coder coder, final byte[] password)
                throws IOException {
            return new BZip2CompressorInputStream(in);
        }
View Full Code Here

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

        try {
            int signatureLength = IOUtils.readFully(in, signature);
            in.reset();

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

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

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream

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

            if (BZIP2.equalsIgnoreCase(name)) {
                return new BZip2CompressorInputStream(in);
            }

            if (XZ.equalsIgnoreCase(name)) {
                return new XZCompressorInputStream(in);
            }
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.