title: finding key with maximum value in java mapreduce
body: <p>I am trying to find the key with max value but an error is generated everytime saying cannot convert text to string. This is related to java mapreduce.</p>
  
  <blockquote>
    <p>Error :
    The method write(Text, IntWritable) in the type TaskInputOutputContext is not applicable for the arguments (String, IntWritable)</p>
  </blockquote>
  
  <p><strong>List</strong>:</p>
  
  <pre><code>994290  5  
  994380  33  
  994410  1  
  994440  11  
  995010  2  
  995030  5  
  </code></pre>
  
  <p><strong>Expected</strong>:</p>
  
  <pre><code>994380  33  
  </code></pre>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>@Override
  public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context)
          throws IOException, InterruptedException {
  
      int max = 0;
      String keyWithMax = "";
      for (IntWritable value : values) {
          if (value.get() &gt; max) {
              max = value.get();
              keyWithMax = key.toString();
          }
      }
      context.write(keyWithMax, new IntWritable(max));
  }
  </code></pre>
  
  <p>Can you please help me in this?</p>