increment date of data that filtered from the text file
<pre><code>public class Reader {
        public static void main(String[] args) throws IOException, ParseException {
            BufferedReader reader;
            String animalName="cat";
            String animal = null;
            try {
                reader = new BufferedReader(new InputStreamReader(
                        new FileInputStream("C:/dila.txt")));
                Map&lt;String, Integer&gt; result = new LinkedHashMap&lt;String, Integer&gt;();
                Map&lt;String, Integer&gt; result2 = new LinkedHashMap&lt;String, Integer&gt;();

                while (reader.ready()) {
                    String line = reader.readLine();
/split a line with spaces/
                    String[] values = line.split(",");
                    String key = null;                 
                    if(values[1].compareTo(animalName)==0){
                    key = values[0];
                    animal=""+values[1].compareTo(animalName);
                    int sum = 0;
                    int count = 0;
/get a last counter and sum/
                    if (result.containsKey(key)) {
                        sum = result.get(key);
                        count = result2.get(key);
                    } else{
                    }
 /increment sum a count and save in the map with key/
                    result.put(key, sum + Integer.parseInt(values[2]));
                    result2.put(key, count + 1);
                }
                }

 /interate and print new output/
                for (String key : result.keySet()) {
                    Integer sum = result.get(key);
                    Integer count = result2.get(key);
                    System.out.println(key +"   "+animalName+ " " + sum + "\t" + count);
                }
                reader.close();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }
</code></pre>

<ul>
    <li>i have below text file<br />
    11/2/2010,cat,6<br />
    11/2/2010,cat,3<br />
    11/2/2010,dog,4<br />
    11/2/2010,cat,11<br />
    11/3/2010,cat,1<br />
    11/3/2010,dog,3<br />
    11/3/2010,cat,8<br />
    11/3/2010,cat,80<br />
    <br />
    </li>
    <li>in my java code it is filtered below output.<br />
    11/2/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 20&nbsp;&nbsp;&nbsp; 3<br />
    11/3/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 104&nbsp;&nbsp;&nbsp; 4<br />
    11/4/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp; 2<br />
    <br />
    </li>
    <li>But i want below mention result.<br />
    11/01/2010<br />
    11/02/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 20&nbsp;&nbsp;&nbsp; 3<br />
    11/03/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 104&nbsp;&nbsp;&nbsp; 4<br />
    11/04/2010&nbsp;&nbsp;&nbsp; cat&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp; 2<br />
    11/05/2010<br />
    11/06/2010<br />
    11/07/2010<br />
    11/08/2010<br />
    11/09/2010<br />
    11/10/2010<br />
    11/11/2010<br />
    11/12/2010<br />
    11/13/2010<br />
    11/14/2010<br />
    11/15/2010<br />
    11/16/2010<br />
    11/17/2010<br />
    11/18/2010<br />
    11/19/2010<br />
    11/20/2010<br />
    11/21/2010<br />
    11/22/2010<br />
    11/23/2010<br />
    11/24/2010<br />
    11/25/2010<br />
    11/26/2010<br />
    11/27/2010<br />
    11/28/2010<br />
    11/29/2010<br />
    11/30/2010<br />
    <br />
    Above shows my java code...(i am new for this site thats why my question is little bit unclear to you. now i got the method. Now i again post my question. So please read this and give me the solution....)</li>
</ul>
