当前位置: 首页>>代码示例>>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;未经允许,请勿转载。