當前位置: 首頁>>代碼示例>>Java>>正文


Java BZip2CompressorOutputStream類代碼示例

本文整理匯總了Java中org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream的典型用法代碼示例。如果您正苦於以下問題:Java BZip2CompressorOutputStream類的具體用法?Java BZip2CompressorOutputStream怎麽用?Java BZip2CompressorOutputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BZip2CompressorOutputStream類屬於org.apache.commons.compress.compressors.bzip2包,在下文中一共展示了BZip2CompressorOutputStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: S3TransportBuffer

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
public S3TransportBuffer(long maxBytes, boolean useCompression, S3TransportSerializer serializer)
    throws TransportException {
  this.maxBytes = maxBytes;
  this.serializer = serializer;

  baos = new ByteArrayOutputStream();
  cos = new CountingOutputStream(baos);

  if (useCompression) {
    this.isCompressed = true;
    try {
      os = new BZip2CompressorOutputStream(cos);
    } catch (IOException e) {
      throw new TransportException("unable to create BZip2CompressorOutputStream", e);
    }
  } else {
    this.isCompressed = false;
    os = cos;
  }
}
 
開發者ID:Nextdoor,項目名稱:bender,代碼行數:21,代碼來源:S3TransportBuffer.java

示例2: getOutputStreamForMode

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
/**
 * Get a compressing stream for a given compression mode.
 */
private OutputStream getOutputStreamForMode(CompressionMode mode, OutputStream stream)
    throws IOException {
  switch (mode) {
    case GZIP:
      return new GzipCompressorOutputStream(stream);
    case BZIP2:
      return new BZip2CompressorOutputStream(stream);
    case ZIP:
      return new TestZipOutputStream(stream);
    case DEFLATE:
      return new DeflateCompressorOutputStream(stream);
    default:
      throw new RuntimeException("Unexpected compression mode");
  }
}
 
開發者ID:apache,項目名稱:beam,代碼行數:19,代碼來源:CompressedSourceTest.java

示例3: openOutput

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
public Writer openOutput(String key) throws UncheckedIOException {
  try {
    if (holdersByKey.containsKey(key)) {
      throw new IllegalStateException("Output already opened");
    }
    FileHolder holder = new FileHolder();
    holdersByKey.put(key, holder);
    return new OutputStreamWriter(new TeeOutputStream(
        new TeeOutputStream(new GZIPOutputStream(Files.newOutputStream(holder.gzTempFile)),
            new BZip2CompressorOutputStream(Files.newOutputStream(holder.bzTempFile))),
        Files.newOutputStream(holder.plainTempFile)), Charsets.UTF_8);
  }
  catch (IOException e) {
    throw new UncheckedIOException(e);
  }
}
 
開發者ID:sonatype-nexus-community,項目名稱:nexus-repository-apt,代碼行數:17,代碼來源:CompressingTempFileStore.java

示例4: testCreateCompressorOutputStreamBzip2

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
@Test
public void testCreateCompressorOutputStreamBzip2() throws Exception {
    new NonStrictExpectations() {{
        task.getFormat(); result = "bzip2";
        task.getBufferAllocator(); result = new MockBufferAllocator();
    }};

    provider = new CommonsCompressCompressorProvider(task, fileOutput);
    OutputStream out = provider.createCompressorOutputStream();
    assertTrue("Verify a stream instance.", out instanceof BZip2CompressorOutputStream);
    provider.close();
    
    new Verifications() {{
        fileOutput.close(); times = 1;
    }};
}
 
開發者ID:hata,項目名稱:embulk-encoder-commons-compress,代碼行數:17,代碼來源:TestCommonsCompressCompressorProvider.java

示例5: zip

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
public static InputStream zip(
        File fileOrDir,
        long[] sizePtr
) throws IOException {
    File tmp = File.createTempFile(fileOrDir.getName(), ".tar.bz2");
    tmp.deleteOnExit();
    OutputStream target = new FileOutputStream(tmp);
    /* Closes target */
    try (OutputStream bzip2 = new BZip2CompressorOutputStream(target)) {
        tarTo(fileOrDir, bzip2);
    }
    if (sizePtr != null) {
        sizePtr[0] = tmp.length();
    }
    return new DeletingFileInputStream(tmp);
}
 
開發者ID:winstonli,項目名稱:writelatex-git-bridge,代碼行數:17,代碼來源:Tar.java

示例6: getCompressedData

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
@Override
protected byte[] getCompressedData() throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try (BZip2CompressorOutputStream os = new BZip2CompressorOutputStream(bos)) {
        os.write(getUncompressedData());
    }

    return bos.toByteArray();
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:10,代碼來源:Bzip2MemDataSourceTest.java

示例7: getBZip2BlockSize

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
int getBZip2BlockSize() {
    final int level = AbstractZipOutputStream.this.getLevel();
    if (BZip2CompressorOutputStream.MIN_BLOCKSIZE <= level
            && level <= BZip2CompressorOutputStream.MAX_BLOCKSIZE)
        return level;
    return BZip2CompressorOutputStream.MAX_BLOCKSIZE;
}
 
開發者ID:christian-schlichtherle,項目名稱:truevfs,代碼行數:8,代碼來源:AbstractZipOutputStream.java

示例8: compress

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
@Override
public byte[] compress(byte[] data) throws IOException {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	BZip2CompressorOutputStream bcos = new BZip2CompressorOutputStream(out);
	bcos.write(data);
	bcos.close();

	return out.toByteArray();
}
 
開發者ID:yu120,項目名稱:compress,代碼行數:10,代碼來源:Bzip2Compress.java

示例9: startRevisionProcessing

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
@Override
public void startRevisionProcessing() {
	logger.debug("Starting (" + featureFile + ")...");
	
	try {
		OutputStreamWriter writer =
				new OutputStreamWriter(
			    getPipedOutputStreamStream(
				new BZip2CompressorOutputStream(
				new BufferedOutputStream(
				new FileOutputStream(featureFile)),
				BZIP2_BLOCKSIZE)),
			    "utf-8");

		String[] header = new String[features.size()];
		
		for (int i = 0; i < features.size(); i++) {
			header[i] = features.get(i).getName();
		}			

		
		csvPrinter = CSVFormat.RFC4180.withHeader(header).print(writer);
		
	} catch (IOException e) {
		logger.error("", e);
	}
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:28,代碼來源:CsvFeatureWriter.java

示例10: run

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
public void run() {
	try {
		// This compression seems to be really slow and is a major bottleneck of the whole program
		OutputStream compressedOutStream = new BZip2CompressorOutputStream(out, 1);
		
		IOUtils.copy(in, compressedOutStream);
		
		in.close();
		compressedOutStream.close();
		out.close();
	} catch (IOException e) {
		logger.error("", e);
	}
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:15,代碼來源:XmlRevisionWriter.java

示例11: bzip2

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
/**
 * Bzip2s the specified array, removing the header.
 *
 * @param uncompressed The uncompressed array.
 * @return The compressed array.
 * @throws IOException If there is an error compressing the array.
 */
public static byte[] bzip2(byte[] uncompressed) throws IOException {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try (BZip2CompressorOutputStream compressor = new BZip2CompressorOutputStream(out, 1)) {
		compressor.write(uncompressed);
		compressor.finish();

		byte[] compressed = out.toByteArray();
		byte[] stripped = new byte[compressed.length - 4]; // Strip the header
		System.arraycopy(compressed, 4, stripped, 0, stripped.length);
		return stripped;
	}
}
 
開發者ID:Major-,項目名稱:Vicis,代碼行數:20,代碼來源:CompressionUtils.java

示例12: openOutputStream

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
public static DataOutputStream openOutputStream(String filename) throws IOException {
  FSUtil.makeParentDirectories(filename);

  if (filename.endsWith(".gz")) {
    return new DataOutputStream(new GZIPOutputStream(new FileOutputStream(filename)));
  } else if (filename.endsWith(".bz") || filename.endsWith(".bz2")) {
    return new DataOutputStream(new BZip2CompressorOutputStream(new FileOutputStream(filename)));
  } else if(filename.endsWith(".xz")) {
    return new DataOutputStream(new XZOutputStream(new FileOutputStream(filename), new LZMA2Options()));
  } else {
    return new DataOutputStream(new FileOutputStream(filename));
  }
}
 
開發者ID:teanalab,項目名稱:demidovii,代碼行數:14,代碼來源:StreamCreator.java

示例13: cacheLibrary

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
private void cacheLibrary (String language, String name)
		throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
		FTPListParseException
{
	File libdir = new File(cachedir, language + "/" + name);
	WorkerMain.getLogger().info("Caching Library " + name + " (" + language + ") to " + libdir.getAbsolutePath());
	libdir.mkdirs();
	DatastoreFtpClient.retrieveLibrary(name, language, libdir);
	File libtar = new File(cachedir, language + "/" + name + ".tar.bz2");
	TarArchiveOutputStream tar = new TarArchiveOutputStream(new BZip2CompressorOutputStream(new FileOutputStream(libtar)));
	tar.setBigNumberMode(BIGNUMBER_POSIX);
	tar.setLongFileMode(LONGFILE_POSIX);
	addToTar(libdir, tar, "");
	tar.close();
}
 
開發者ID:Turnierserver,項目名稱:Turnierserver,代碼行數:16,代碼來源:LibraryCache.java

示例14: compressBzip2

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
private byte[] compressBzip2 ( final byte[] data ) throws IOException
{
    final ByteArrayOutputStream bos = new ByteArrayOutputStream ();
    final BZip2CompressorOutputStream b2os = new BZip2CompressorOutputStream ( bos );

    b2os.write ( data );

    b2os.close ();
    return bos.toByteArray ();
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:11,代碼來源:RepoBuilder.java

示例15: createCompressorOutputStream

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入依賴的package包/類
CompressorOutputStream createCompressorOutputStream() throws IOException {
    switch (format) {
    case BZIP2:
        return new BZip2CompressorOutputStream(output);
    case DEFLATE:
        return new DeflateCompressorOutputStream(output);
    case GZIP:
        return new GzipCompressorOutputStream(output);
    }

    // Normally, this exception is not thrown.
    throw new IOException("Unknown format found.");
}
 
開發者ID:hata,項目名稱:embulk-encoder-commons-compress,代碼行數:14,代碼來源:CommonsCompressCompressorProvider.java


注:本文中的org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。