code: public static void main(String[] args) throws Exception {
      Configuration conf = new Configuration();
      CompressionCodecFactory factory = new CompressionCodecFactory(conf);
      boolean encode = false;
      for(int i=0; i < args.length; ++i) {
        if ("-in".equals(args[i])) {
          encode = true;
        } else if ("-out".equals(args[i])) {
          encode = false;
        } else {
          CompressionCodec codec = factory.getCodec(new Path(args[i]));
          if (codec == null) {
            System.out.println("Codec for " + args[i] + " not found.");
          } else { 
            if (encode) {
              CompressionOutputStream out = 
                codec.createOutputStream(new java.io.FileOutputStream(args[i]));
              byte[] buffer = new byte[100];
              String inFilename = removeSuffix(args[i], 
                                               codec.getDefaultExtension());
              java.io.InputStream in = new java.io.FileInputStream(inFilename);
              int len = in.read(buffer);
              while (len > 0) {
                out.write(buffer, 0, len);
                len = in.read(buffer);
              }
              in.close();
              out.close();
            } else {
              CompressionInputStream in = 
                codec.createInputStream(new java.io.FileInputStream(args[i]));
              byte[] buffer = new byte[100];
              int len = in.read(buffer);
              while (len > 0) {
                System.out.write(buffer, 0, len);
                len = in.read(buffer);
              }
              in.close();
            }
          }
        }
      }
    }
docs: A little test program.
  @param args