title: Reading and Writing Sequencefile using Hadoop 2.0 Apis
body: <p>I am looking for an example which is using the new API to read and write Sequence Files.</p>
  
  <p>Effectively I need to know how to use these functions</p>
  
  <pre><code> createWriter(Configuration conf, org.apache.hadoop.io.SequenceFile.Writer.Option... opts) 
  </code></pre>
  
  <p>The Old definition is not working for me:</p>
  
  <pre><code>SequenceFile.createWriter( fs, conf, path, key.getClass(), value.getClass());
  </code></pre>
  
  <p>Similarly I need to know what will be the code for reading the Sequence file, as the follwoing is deprecated:</p>
  
  <pre><code>SequenceFile.Reader(fs, path, conf);
  </code></pre>
  
  <hr>
  
  <p>Here is the way to use the same -</p>
  
  <pre><code>    String uri = args[0];
      Configuration conf = new Configuration();
      Path path = new Path( uri);
  
      IntWritable key = new IntWritable();
      Text value = new Text();
  
      CompressionCodec Codec = new GzipCodec();
      SequenceFile.Writer writer = null;
      Option optPath = SequenceFile.Writer.file(path);
      Option optKey = SequenceFile.Writer.keyClass(key.getClass());
      Option optVal = SequenceFile.Writer.valueClass(value.getClass());
      Option optCom = SequenceFile.Writer.compression(CompressionType.RECORD,  Codec);
  
          writer = SequenceFile.createWriter( conf, optPath, optKey, optVal, optCom);
  </code></pre>