title: Splitting the tokens with Java StringTokenizer
body: <p>I have a data set that looks like this:</p>
  <pre><code>drawdate    lotterynumbers  meganumber  multiplier
  2005-01-04  03 06 07 12 32  30            NULL
  2005-01-07  02 08 14 15 51  38            NULL
  etc.
  </code></pre>
  <p>and the following code:</p>
  <pre><code>public class LotteryCount {
  
      /**
       * Mapper which extracts the lottery number and passes it to the Reducer with a single occurrence
       */
      public static class LotteryMapper extends Mapper&lt;Object, Text, IntWritable, IntWritable&gt; {
  
          private final static IntWritable one = new IntWritable(1);
          private IntWritable lotteryKey;
  
          public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
  
              StringTokenizer itr = new StringTokenizer(value.toString(), &quot;,&quot;);
              while (itr.hasMoreTokens()) {
                  lotteryKey.set(Integer.valueOf(itr.nextToken()));
                  context.write(lotteryKey, one);
              }
          }
      }
  
      /**
       * Reducer to sum up the occurrence
       */
      public static class LotteryReducer
              extends Reducer&lt;IntWritable, IntWritable, IntWritable, IntWritable&gt; {
          IntWritable result = new IntWritable();
  
          public void reduce(IntWritable key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException {
              int sum = 0;
  
              for (IntWritable val : values) {
                  sum += val.get();
              }
  
              result.set(sum);
              context.write(key, result);
          }
      }
  }
  </code></pre>
  <p>It is actually the word count from the official apache hadoop documentation, just a bit customized to my data set.</p>
  <p>I get the following error:</p>
  <pre><code>Caused by: java.lang.NumberFormatException: For input string: &quot;2005-01-04&quot;
  </code></pre>
  <p>I am just interested in counting the  occurrences for each individual drawn lottery number. How can I do this by using the StringTokenizer from my code? I know that I have to split the whole row because the tokenizer is &quot;fed&quot; with the whole. How can I take the lotterynumbers, split them and then count?</p>
  <p>Thank you in advance</p>