How to sort the count received after reading multiple files
<p>I'm new to Java and need help for sorting using HashMap or TreeMap.I need to display the count of total no. of disconnects corresponding to a particular computer name.User enters the date range for which the computer name and count is displayed.Data is read from multiple files which contain data like:
FILE 1</p>

<pre><code>[C417] ComputerName:KCUTSHALL-PC UserID:GO kcutshall Station 9900 (locked) LanId: | (11/23 11:36:13) | Client is disconnected from agent.
[C417] ComputerName:KCUTSHALL-PC UserID:GO kcutshall Station 9900 (locked) LanId: | (11/23 11:36:13) | Client is connected to agent
</code></pre>

<p>FILE 2:</p>

<pre><code>[C445] ComputerName:FRONTOFFICE UserID:YB Yenae Ball Station 7A  LanId: | (11/23 17:01:55) | Client is disconnected from agent.
[C445] ComputerName:KCUTSHALL-PC UserID:GO kcutshall Station 9900 (locked) LanId: | (11/23 17:02:00) | Client is disconnected from agent.
</code></pre>

<p>OUTPUT REQUIRED:</p>

<pre><code>Computer Name    No. of disconnects
KCUTSHALL-PC          2
FRONTOFFICE           1
</code></pre>

<p>No. of disconnects should be in descending order.I tried doing with HashMap but didnt get the desired output.Please edit my code or show me how can I get a consolidated count while reading through multiple files.Thanks a lot in advance. Here is what I wrote</p>

<pre><code>enter code here
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.Scanner;
import java.util.*;
import java.text.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;


public class ReadZip{
  public static void main(String args[]) throws ParseException {
    try {
Scanner input1=new Scanner(System.in);

   Scanner input2=new Scanner(System.in);
   System.out.println("Enter start date");
    String userDate1=input1.nextLine();
    System.out.println("Enter end date");
     String userDate2=input2.nextLine();
DateFormat df = new SimpleDateFormat ("MM/dd");
      Date d1=df.parse(userDate1);
      Date d2=df.parse(userDate2);

      ZipFile zf=new ZipFile("C:\\Users\\Engineeir\\Desktop\\QoS_logs.zip");
      Enumeration entries=zf.entries();

      BufferedReader input=new BufferedReader(new InputStreamReader(
          System.in));
      while (entries.hasMoreElements()) {
        ZipEntry ze=(ZipEntry) entries.nextElement();

     BufferedReader br=new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
        String line; String name;String compnames;int lines=0;
        while ((line=br.readLine())!=null) {

       String[] st=line.split("\\|",-1);
if(st.length&gt;1){
String dates=st[1];
 String[] parts=dates.split("-");
 SimpleDateFormat f=new SimpleDateFormat("(MM/dd");
String[] ob=parts[0].split(" ");
String finaldate=ob[1];
HashMap first=new HashMap(); 
Date d3=f.parse(finaldate);
if((d3.after(d1) &amp;&amp; d3.before(d2)) &amp;&amp; line.contains("Client is disconnected from agent")==true)
{
compnames=getName(st);
lines++;}

else{break;}
first.put(compnames,lines);
ArrayList as=new ArrayList(first.entrySet());  

        Collections.sort(as,new Comparator(){  
            public int compare(Object o1,Object o2)  
            {  
                Map.Entry e1=(Map.Entry)o1 ;  
                Map.Entry e2=(Map.Entry)o2 ;  
                Integer first=(Integer)e1.getValue();  
                Integer second=(Integer)e2.getValue();  
                return second.compareTo(first);  
            }  
  });
  Iterator i=as.iterator();  
        while(i.hasNext())  
        {  
            System.out.println((Map.Entry)i.next());  
        }

}



       //br.close();
}  }  }catch (IOException e) {
      e.printStackTrace();
    }}

      public static String getName(String[] st)
    {
       String[] name=st[0].split("\\:",-1);
       String[] comp=name[1].split("\\ ",-1);

        return(comp[0]);
    }}
</code></pre>
