使用压缩池对读取自标准的谁的数据进行压缩,然后将其写到标准输

//使用压缩池对读取自标准的谁的数据进行压缩,,然后将其写到标准输出package com;import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.io.IOUtils;import org.apache.hadoop.io.compress.CodecPool;import org.apache.hadoop.io.compress.CompressionCodec;import org.apache.hadoop.io.compress.CompressionOutputStream;import org.apache.hadoop.io.compress.Compressor;import org.apache.hadoop.util.ReflectionUtils;public class PooledStreamCompressor {/*** @param args* @throws IOException* @throws ClassNotFoundException*/public static void main(String[] args) throws IOException, ClassNotFoundException {// TODO Auto-generated method stubString codecClassname = args[0];Class<?> codecClass = Class.forName(codecClassname);Configuration conf = new Configuration();CompressionCodec codec = (CompressionCodec)ReflectionUtils.newInstance(codecClass, conf);Compressor compressor = null;try{compressor = CodecPool.getCompressor(codec);CompressionOutputStream out = codec.createOutputStream(System.out, compressor);IOUtils.copyBytes(System.in, out, 4096, false);out.finish();}finally{CodecPool.returnCompressor(compressor);}}}

仿佛松树就是一位威风的将军,守护着国家的国民。

使用压缩池对读取自标准的谁的数据进行压缩,然后将其写到标准输

相关文章:

你感兴趣的文章:

标签云: