Package org.apache.commons.compress.compressors.bzip2

Examples of org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream$Data


     */
    public static byte[] extractBZip2(byte[] bytes) {
        try {
            InputStream bytesIS = new ByteArrayInputStream(bytes);
            ByteArrayOutputStream bytesUncompressedOS = new ByteArrayOutputStream();
            BZip2CompressorInputStream bzip2CompressorIS = new BZip2CompressorInputStream(bytesIS);

            ByteStreams.copy(bzip2CompressorIS, bytesUncompressedOS);
            bzip2CompressorIS.close();

            return bytesUncompressedOS.toByteArray();
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Error while uncompressing", e);
            return null;
View Full Code Here


        if ("gz".equalsIgnoreCase(FilenameUtils.getExtension(name))) {
            is = new GZIPInputStream(is);
            name = FilenameUtils.removeExtension(name);
            log.debug("   - from GZIP Archive");
        } else if ("bz2".equalsIgnoreCase(FilenameUtils.getExtension(name))) {
            is = new BZip2CompressorInputStream(is);
            name = FilenameUtils.removeExtension(name);
            log.debug("   - from BZip2 Archive");
        }// TODO: No Zip Files inside Zip Files supported :o( ^^
        Lang format = Lang.guess(name);
        // For N-Triple we can use the TDBLoader
View Full Code Here

            in = new ZipInputStream(in);
            ((ZipInputStream)in).getNextEntry();
        } else if("gz".equalsIgnoreCase(extension)) {
            in = new GZIPInputStream(in);
        } else if("bz2".equalsIgnoreCase(extension)) {
            in = new BZip2CompressorInputStream(in);
        }
        return in;
    }
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

      case NONE:
        return inputStream;
      case GZIP:
        return new GZIPInputStream(inputStream);
      case BZIP2:
        return new BZip2CompressorInputStream(inputStream);
      default:
        throw new IllegalArgumentException("Could not adapt unknown compression " + compression);
    }
  }
View Full Code Here

    }
    if (name.endsWith(".deflate")) {
      return new InflaterInputStream(in);
    }
    if (name.endsWith(".bz2") || name.endsWith(".bzip2")) {
      return new BZip2CompressorInputStream(in);
    }
    return in;
  }
View Full Code Here

      } else if ("application/gzip".equals(partContentType)) {
        in = new GZIPInputStream(in);
      } else if ("application/x-gzip".equals(partContentType)) {
        in = new GZIPInputStream(in);
      } else if ("application/bzip2".equals(partContentType)) {
        in = new BZip2CompressorInputStream(in);
      } else if ("application/x-bzip2".equals(partContentType)) {
        in = new BZip2CompressorInputStream(in);
      }
      reader = new InputStreamReader(in, Charsets.UTF_8);

    } else {

      String charEncodingName = request.getCharacterEncoding();
      Charset charEncoding = charEncodingName == null ? Charsets.UTF_8 : Charset.forName(charEncodingName);
      String contentEncoding = request.getHeader(HttpHeaders.CONTENT_ENCODING);
      if (contentEncoding == null) {
        reader = request.getReader();
      } else if ("gzip".equals(contentEncoding)) {
        reader = new InputStreamReader(new GZIPInputStream(request.getInputStream()), charEncoding);
      } else if ("zip".equals(contentEncoding)) {
        reader = new InputStreamReader(new ZipInputStream(request.getInputStream()), charEncoding);
      } else if ("bzip2".equals(contentEncoding)) {
        reader = new InputStreamReader(new BZip2CompressorInputStream(request.getInputStream()), charEncoding);
      } else {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unsupported Content-Encoding");
        return;
      }
View Full Code Here

            final long inputFileSize = inputArchive.length();

            if(inputArchive.getName().endsWith(".tbz2")) {
                archiveInputStream = new TarArchiveInputStream(
                        new BZip2CompressorInputStream(inputStream));
            } else {
                archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(
                        new BufferedInputStream(inputStream));
            }
View Full Code Here

      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

        is.close();
    }

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

TOP

Related Classes of org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream$Data

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.