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


Java BZip2CompressorOutputStream.close方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: compressData

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入方法依賴的package包/類
/**
 * Compress data
 * 
 * @param fileCompressor
 *            FileCompressor object
 * @return
 * @throws Exception
 */
@Override
public byte[] compressData(FileCompressor fileCompressor) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BZip2CompressorOutputStream cos = new BZip2CompressorOutputStream(baos);
    ZipOutputStream zos = new ZipOutputStream(cos);
    try {
        zos.setLevel(fileCompressor.getLevel().getValue());
        zos.setMethod(ZipOutputStream.DEFLATED);
        zos.setComment(fileCompressor.getComment());
        for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile()
                .values()) {
            zos.putNextEntry(new ZipEntry(binaryFile.getDesPath()));
            zos.write(binaryFile.getData());
            zos.closeEntry();
        }
        zos.flush();
        zos.finish();
    } catch (Exception e) {
        FileCompressor.LOGGER.error("Error on compress data", e);
    } finally {
        zos.close();
        cos.close();
        baos.close();
    }
    return baos.toByteArray();
}
 
開發者ID:espringtran,項目名稱:compressor4j,代碼行數:35,代碼來源:Bzip2Processor.java

示例4: compressData

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入方法依賴的package包/類
/**
 * Compress data
 * 
 * @param fileCompressor
 *            FileCompressor object
 * @return
 * @throws Exception
 */
@Override
public byte[] compressData(FileCompressor fileCompressor) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BZip2CompressorOutputStream cos = new BZip2CompressorOutputStream(baos);
    TarArchiveOutputStream aos = new TarArchiveOutputStream(cos);
    try {
        for (BinaryFile binaryFile : fileCompressor.getMapBinaryFile()
                .values()) {
            TarArchiveEntry entry = new TarArchiveEntry(
                    binaryFile.getDesPath());
            entry.setSize(binaryFile.getActualSize());
            aos.putArchiveEntry(entry);
            aos.write(binaryFile.getData());
            aos.closeArchiveEntry();
        }
        aos.flush();
        aos.finish();
    } catch (Exception e) {
        FileCompressor.LOGGER.error("Error on compress data", e);
    } finally {
        aos.close();
        cos.close();
        baos.close();
    }
    return baos.toByteArray();
}
 
開發者ID:espringtran,項目名稱:compressor4j,代碼行數:35,代碼來源:TarBz2Processor.java

示例5: bzip2

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入方法依賴的package包/類
public static void bzip2(File f, File bz2f) throws Throwable {

		BufferedInputStream is = new BufferedInputStream(new FileInputStream(f), BUFFER_SIZE);
		BZip2CompressorOutputStream os = new BZip2CompressorOutputStream(new BufferedOutputStream(new FileOutputStream(
				bz2f), BUFFER_SIZE));
		try {
			IOUtils.copy(is, os, BUFFER_SIZE);
			os.flush();
		} finally {
			os.close();
			is.close();
		}

	}
 
開發者ID:uom-daris,項目名稱:daris,代碼行數:15,代碼來源:BZip2Util.java

示例6: doCompress

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入方法依賴的package包/類
@Override
protected byte[] doCompress(byte[] plain) throws IOException {

    @Cleanup ByteArrayOutputStream bos = new ByteArrayOutputStream();
    @Cleanup BZip2CompressorOutputStream bzip2 = new BZip2CompressorOutputStream(bos);

    bzip2.write(plain);
    bzip2.close();

    return bos.toByteArray();
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:12,代碼來源:BZip2Compressor.java

示例7: bzip2

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; //導入方法依賴的package包/類
/**
 * Bzip2s the specified array.
 * 
 * @param bytes The uncompressed array.
 * @return The compressed array.
 * @throws IOException If an I/O error occurs.
 */
public static byte[] bzip2(byte[] bytes) throws IOException {
	ByteArrayOutputStream bout = new ByteArrayOutputStream();
	BZip2CompressorOutputStream os = new BZip2CompressorOutputStream(bout, 1);
	try {
		os.write(bytes);
		os.finish();
		byte[] compressed = bout.toByteArray();
		byte[] newCompressed = new byte[compressed.length - 4];
		System.arraycopy(compressed, 4, newCompressed, 0, newCompressed.length);
		return newCompressed;
	} finally {
		os.close();
	}
}
 
開發者ID:DealerNextDoor,項目名稱:ApolloDev,代碼行數:22,代碼來源:CompressionUtil.java


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