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


Java CompressorStreamFactory.GZIP屬性代碼示例

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


在下文中一共展示了CompressorStreamFactory.GZIP屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: afterPropertiesSet

@Override
public void afterPropertiesSet() throws Exception
{
   // Compression type is optional, use GZip if in doubt
   if (compressionType == null || compressionType.isEmpty())
   {
      compressionType = CompressorStreamFactory.GZIP;
   }
   
   // Real Content Store and MimeTypes must be given
   if (compressMimeTypes == null || compressMimeTypes.isEmpty())
   {
      throw new IllegalArgumentException("'compressMimeTypes' must be given");
   }
   if (realContentStore == null)
   {
      throw new IllegalArgumentException("'realContentStore' must be given");
   }
   if (mimetypeService == null)
   {
      throw new IllegalArgumentException("'mimetypeService' must be given");
   }
}
 
開發者ID:Gagravarr,項目名稱:AlfrescoCompressingContentStore,代碼行數:23,代碼來源:CompressingContentStore.java

示例3: getReadableChannel

/**
 * {@inheritDoc}
 */
@Override
public synchronized ReadableByteChannel getReadableChannel() throws ContentIOException
{
    this.ensureDelegate();
    final String mimetype = this.getMimetype();

    final boolean shouldCompress = this.mimetypesToCompress == null || this.mimetypesToCompress.isEmpty()
            || (mimetype != null && (this.mimetypesToCompress.contains(mimetype) || this.isMimetypeToCompressWildcardMatch(mimetype)));

    ReadableByteChannel channel;
    if (shouldCompress)
    {
        LOGGER.debug("Content will be decompressed from backing store (url={})", this.getContentUrl());

        final String compressiongType = this.compressionType != null && !this.compressionType.trim().isEmpty() ? this.compressionType
                : CompressorStreamFactory.GZIP;
        try
        {
            final CompressorInputStream is = COMPRESSOR_STREAM_FACTORY.createCompressorInputStream(compressiongType,
                    this.delegate.getContentInputStream());
            channel = Channels.newChannel(is);
        }
        catch (final CompressorException e)
        {
            LOGGER.error("Failed to open decompressing channel", e);
            throw new ContentIOException("Failed to open channel: " + this, e);
        }
    }
    else
    {
        LOGGER.debug("Content will not be decompressed from backing store (url={})", this.getContentUrl());
        channel = super.getReadableChannel();
    }

    return channel;
}
 
開發者ID:Acosix,項目名稱:alfresco-simple-content-stores,代碼行數:39,代碼來源:DecompressingContentReader.java

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

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

示例6: writeToBackingStore

protected void writeToBackingStore()
{
    String mimetype = this.getMimetype();
    LOGGER.debug("Determined mimetype {} from write into temporary store", mimetype);

    if ((this.mimetypesToCompress != null && !this.mimetypesToCompress.isEmpty()) && this.mimetypeService != null
            && (mimetype == null || MimetypeMap.MIMETYPE_BINARY.equals(mimetype)))
    {
        mimetype = this.mimetypeService.guessMimetype(null, this.createReader());
        LOGGER.debug("Determined mimetype {} from MimetypeService.guessMimetype()", mimetype);

        if (mimetype == null || MimetypeMap.MIMETYPE_BINARY.equals(mimetype))
        {
            this.setMimetype(mimetype);
        }
    }

    try
    {
        final boolean shouldCompress = this.mimetypesToCompress == null || this.mimetypesToCompress.isEmpty() || (mimetype != null
                && (this.mimetypesToCompress.contains(mimetype) || this.isMimetypeToCompressWildcardMatch(mimetype)));
        if (shouldCompress)
        {
            LOGGER.debug("Content will be compressed to backing store (url={})", this.getContentUrl());
            final String compressiongType = this.compressionType != null && !this.compressionType.trim().isEmpty()
                    ? this.compressionType : CompressorStreamFactory.GZIP;
            try (final OutputStream contentOutputStream = this.backingWriter.getContentOutputStream())
            {
                try (OutputStream compressedOutputStream = COMPRESSOR_STREAM_FACTORY.createCompressorOutputStream(compressiongType,
                        contentOutputStream))
                {
                    final ContentReader reader = this.createReader();
                    final InputStream contentInputStream = reader.getContentInputStream();
                    FileCopyUtils.copy(contentInputStream, compressedOutputStream);
                }
            }
            catch (final IOException | CompressorException ex)
            {
                throw new ContentIOException("Error writing compressed content", ex);
            }
        }
        else
        {
            LOGGER.debug("Content will not be compressed to backing store (url={})", this.getContentUrl());
            this.backingWriter.putContent(this.createReader());
        }

        final String finalContentUrl = this.backingWriter.getContentUrl();
        // we don't expect a different content URL, but just to make sure
        this.setContentUrl(finalContentUrl);
    }
    finally
    {
        this.writtenToBackingWriter = true;
    }
}
 
開發者ID:Acosix,項目名稱:alfresco-simple-content-stores,代碼行數:56,代碼來源:CompressingContentWriter.java

示例7: CompressorSerializer

public CompressorSerializer(ISerializer<Object> serializer) {
    this.serializer=serializer;
    this.compressor=new CommonsCompressor(CompressorStreamFactory.GZIP);
}
 
開發者ID:qiujiayu,項目名稱:AutoLoadCache,代碼行數:4,代碼來源:CompressorSerializer.java

示例8: CommonsCompress

public CommonsCompress()
{
    this.type = CompressorStreamFactory.GZIP;
}
 
開發者ID:liulhdarks,項目名稱:darks-codec,代碼行數:4,代碼來源:CommonsCompress.java

示例9: Tarball

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


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