title: How to format the output being written by Mapreduce in Hadoop
body: <p>I am trying to reverse the contents of the file by each word. I have the program running fine, but the output i am getting is something like this</p>
  
  <pre><code>1   dwp
  2   seviG
  3   eht
  4   tnerruc
  5   gnikdrow
  6   yrotcerid
  7   ridkm
  8   desU
  9   ot
  10  etaerc
  </code></pre>
  
  <p>I want the output to be something like this</p>
  
  <pre><code>dwp seviG eht tnerruc gnikdrow yrotcerid ridkm desU
  ot etaerc
  </code></pre>
  
  <p>The code i am working with</p>
  
  <pre><code>    import java.io.IOException;
      import java.util.*;
  
      import org.apache.hadoop.fs.Path;
      import org.apache.hadoop.conf.*;
      import org.apache.hadoop.io.*;
      import org.apache.hadoop.mapred.*;
      import org.apache.hadoop.util.*;
  
      public class Reproduce {
  
      public static int temp =0;
      public static class ReproduceMap extends MapReduceBase implements Mapper&lt;LongWritable, Text, IntWritable, Text&gt;{
          private Text word = new Text();
          @Override
          public void map(LongWritable arg0, Text value,
                  OutputCollector&lt;IntWritable, Text&gt; output, Reporter reporter)
                  throws IOException {
              String line = value.toString().concat("\n");
              StringTokenizer tokenizer = new StringTokenizer(line);
              while (tokenizer.hasMoreTokens()) {
                  word.set(new StringBuffer(tokenizer.nextToken()).reverse().toString());
                  temp++;
                  output.collect(new IntWritable(temp),word);
                }
  
          }
  
      }
  
      public static class ReproduceReduce extends MapReduceBase implements Reducer&lt;IntWritable, Text, IntWritable, Text&gt;{
  
          @Override
          public void reduce(IntWritable arg0, Iterator&lt;Text&gt; arg1,
                  OutputCollector&lt;IntWritable, Text&gt; arg2, Reporter arg3)
                  throws IOException {
              String word = arg1.next().toString();
              Text word1 = new Text();
              word1.set(word);
              arg2.collect(arg0, word1);
  
          }
  
      }
  
      public static void main(String[] args) throws Exception {
      JobConf conf = new JobConf(WordCount.class);
      conf.setJobName("wordcount");
  
      conf.setOutputKeyClass(IntWritable.class);
      conf.setOutputValueClass(Text.class);
  
      conf.setMapperClass(ReproduceMap.class);
      conf.setReducerClass(ReproduceReduce.class);
  
      conf.setInputFormat(TextInputFormat.class);
      conf.setOutputFormat(TextOutputFormat.class);
  
      FileInputFormat.setInputPaths(conf, new Path(args[0]));
      FileOutputFormat.setOutputPath(conf, new Path(args[1]));
  
      JobClient.runJob(conf);
  
    }
  }
  </code></pre>
  
  <p>How do i modify my output instead of writing another java program to do that</p>
  
  <p>Thanks in advance</p>