title: multiple outputs hadoop
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3491105/multipleoutputformat-in-hadoop">MultipleOutputFormat in hadoop</a>  </p>
  </blockquote>
  
  
  
  <p>How can I change the code in the WordCount.java program in the examples such that the output of the WordCounts for each file is put on separate files. That is, instead of having a single wordcount all files in that default part-00000 file. Also the output file always has the name part-00000 or some other name along those lines, can I chose the output filename I want for this file, and if so how?</p>
  
  <p>I imagine I have to configure this in the main somehow, but I have searched on this and I can't find how to do this?</p>
  
  <pre><code>  public static void main(String[] args) throws Exception {
      Configuration conf = new Configuration();
      String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
      if (otherArgs.length != 2) {
        System.err.println("Usage: wordcount &lt;in&gt; &lt;out&gt;");
        System.exit(2);
      }
      Job job = new Job(conf, "word count");
      job.setJarByClass(WordCount.class);
      job.setMapperClass(TokenizerMapper.class);
      job.setCombinerClass(IntSumReducer.class);
      job.setReducerClass(IntSumReducer.class);
      job.setOutputKeyClass(Text.class);
      job.setOutputValueClass(IntWritable.class);
      FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
      FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
      System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
  </code></pre>
  
  <p>Any help appreciated,
  Ted</p>