read line using java & maped filterd data.
    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<String, Integer> result = new LinkedHashMap<String, Integer>();
                    Map<String, Integer> result2 = new LinkedHashMap<String, Integer>();
    
                    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();
                }
    
            }
        }




<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</li>
</ul>
i hav bulk of data seperated from &quot;,&quot; . so iwant to read line and split. &amp; i hav done it. but my requrment is above shown result. <br />

read line using java & maped filterd data.
===

    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<String, Integer> result = new LinkedHashMap<String, Integer>();
                    Map<String, Integer> result2 = new LinkedHashMap<String, Integer>();
    
                    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();
                }
    
            }
        }




<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</li>
</ul>
i hav bulk of data seperated from &quot;,&quot; . so iwant to read line and split. &amp; i hav done it. but my requrment is above shown result. <br />
