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


Java CompressorStreamFactory.BZIP2屬性代碼示例

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


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

示例1: testOpenForGeneratedCompression

@Test
public void testOpenForGeneratedCompression() throws Exception
{
    String[] testFormats = new String[]{
            CompressorStreamFactory.BZIP2,
            CompressorStreamFactory.DEFLATE,
            CompressorStreamFactory.GZIP,
            // CompressorStreamFactory.LZMA, // CompressorException: Compressor: lzma not found.
            // CompressorStreamFactory.PACK200, // Failed to generate compressed file.
            // CompressorStreamFactory.SNAPPY_FRAMED, // CompressorException: Compressor: snappy-framed not found.
            // CompressorStreamFactory.SNAPPY_RAW, // CompressorException: Compressor: snappy-raw not found.
            // CompressorStreamFactory.XZ, // ClassNotFoundException: org.tukaani.xz.FilterOptions
            // CompressorStreamFactory.Z, // CompressorException: Compressor: z not found.
    };

    for (String format : testFormats) {
        TaskSource mockTaskSource = new MockTaskSource(format);
        FileInput mockInput = new MockFileInput(
                getInputStreamAsBuffer(
                        getCompressorInputStream(format, "sample_1.csv")));
        CommonsCompressDecoderPlugin plugin = new CommonsCompressDecoderPlugin();
        FileInput archiveFileInput = plugin.open(mockTaskSource, mockInput);
        verifyContents(archiveFileInput, "1,foo");
    }
}
 
開發者ID:hata,項目名稱:embulk-decoder-commons-compress,代碼行數:25,代碼來源:TestCommonsCompressDecoderPlugin.java

示例2: normalizeFormats

private static String[] normalizeFormats(String... formats) {
    if (formats == null || formats.length == 0) {
        return formats;
    }

    for (int i = 0;i < formats.length;i++) {
        if (formats[i].equalsIgnoreCase("gzip")) {
            formats[i] = CompressorStreamFactory.GZIP;
        } else if (formats[i].equalsIgnoreCase("bz2")) {
            formats[i] = CompressorStreamFactory.BZIP2;
        }
    }

    return formats;
}
 
開發者ID:hata,項目名稱:embulk-decoder-commons-compress,代碼行數:15,代碼來源:CommonsCompressUtil.java

示例3: testToFormatsForMultipleFormats

@Test
public void testToFormatsForMultipleFormats() {
    String format = ArchiveStreamFactory.TAR + " " + CompressorStreamFactory.BZIP2;
    String[] formats = CommonsCompressUtil.toFormats(format);
    assertEquals("Two format text returns 2 length array.", 2, formats.length);
    assertEquals("Two format text returns bzip2 for 1st element.", CompressorStreamFactory.BZIP2, formats[0]);
    assertEquals("Two format text returns tar for 1st element.", ArchiveStreamFactory.TAR, formats[1]);
}
 
開發者ID:hata,項目名稱:embulk-decoder-commons-compress,代碼行數:8,代碼來源:TestCommonsCompressUtil.java

示例4: detectCompression

/**
 * Detect the compression format from the filename, or null in case auto-detection failed.
 * @param file
 * @return
 */
private String detectCompression(File file) {
    if(BZip2Utils.isCompressedFilename(file.getName())) {
        return CompressorStreamFactory.BZIP2;
    } else if(GzipUtils.isCompressedFilename(file.getName())) {
        return CompressorStreamFactory.GZIP;
    } else if(XZUtils.isCompressedFilename(file.getName())) {
        return CompressorStreamFactory.XZ;
    } else {
        return null;
    }
}
 
開發者ID:apache,項目名稱:marmotta,代碼行數:16,代碼來源:MarmottaLoader.java

示例5: TarBzip2

/**
 * Constructs a new instance of this class using the TAR constant of
 * {@link ArchiveStreamFactory} and the BZIP2 constant of
 * {@link CompressorStreamFactory}.
 */
public TarBzip2() {
    super(ArchiveStreamFactory.TAR, CompressorStreamFactory.BZIP2);
}
 
開發者ID:turbolocust,項目名稱:GZipper,代碼行數:8,代碼來源:TarBzip2.java


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