title: Comparing two lines in text file & printing single line corresponding to similar dates
body: <p>I want to take line 1 and line 5 which has username and date same but in line one it contains in time,and in line 5 it contain out time 
  I want to read those two lines and compare it to check whether both lines have same username and date and if so print it as single line in some other text file or in hash map </p>
  
  <p>example like this : <code>"sangeetha-May 02, 2013 , -in-09:48:06:61 -out-08:08:19:27</code> (in JAVA)</p>
  
  <p>This is the content of text file :</p>
  
  <pre><code>line 1. "sangeetha-May 02, 2013 , -in-09:48:06:61
  line 2. "lohith-May 01, 2013 , -out-09:10:41:61
  line 3 . "sushma-May 02, 2013 , -in-09:48:06:61
  line 4. "sangeetha-May 01, 2013 , -out-08:36:38:50
  line 5. "sangeetha-May 02, 2013 , -out-08:08:19:27
  line 6. "sushma-May 02, 2013 , -out-07:52:13:51
  line 7. "sangeetha-Jan 01, 2013 , -in-09:27:17:52-out-06:47:48:00
  line 8. "madhusudhan-Jan 01, 2013 , -in-09:38:59:31-out-07:41:06:40
  </code></pre>
  
  <p>Above data is generating by using code below</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.HashSet;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Set;
  import java.util.Map;
  import java.util.TreeMap;
  
  public class FlatFileParser 
  {
      public static void main(String[] args)
      {    
          // The stream we're reading from
          BufferedReader in;
          BufferedWriter out1;
           BufferedWriter out2;
          // Return value of next call to next()
          String nextline;
          try 
          {
              if (args[0].equals("1"))
              {
                  in = new BufferedReader(new FileReader(args[1]));
                  nextline = in.readLine();
                  while(nextline != null)
                  {
                      nextline = nextline.replaceAll("\\&lt;packet","\n&lt;packet");
                      System.out.println(nextline);
                      nextline = in.readLine();
                  }
                  in.close();
              }
              else
              {
                  in = new BufferedReader(new FileReader(args[1]));
                  out1 = new BufferedWriter(new FileWriter("inValues.txt" , true));
                   out2 = new BufferedWriter(new FileWriter("outValues.txt"));
                  nextline = in.readLine();
                  HashMap&lt;String,String&gt; inout = new HashMap&lt;String,String&gt;();
                  while(nextline != null)
                  {
                      try
                      {
                          if (nextline.indexOf("timetracker")&gt;0)
                          {
                              String from = "";
                              String indate = "";
                              if (nextline.indexOf("of in")&gt;0)
                              {
  
                                  int posfrom = nextline.indexOf("from");
                                  int posnextAt = nextline.indexOf("@", posfrom);
                                  int posts = nextline.indexOf("timestamp");
                                  from = nextline.substring(posfrom+5,posnextAt);
                                  indate = nextline.substring(posts+11, posts+23);
                                  String dd = indate.split(" ")[1];
                                  String key = dd+"-"+from+"-"+indate;
                                  //String key = from+"-"+indate;
                                  String intime = "-in-"+nextline.substring(posts+24, posts+35);
                                  inout.put(key, intime);    
  
                              }
                              else if (nextline.indexOf("of out")&gt;0)
                              {
                                  int posfrom = nextline.indexOf("from");
                                  int posnextAt = nextline.indexOf("@", posfrom);
                                  int posts = nextline.indexOf("timestamp");
                                  from = nextline.substring(posfrom+5,posnextAt);
                                  indate = nextline.substring(posts+11, posts+23);
                                  String dd = indate.split(" ")[1];
                                  String key = dd+"-"+from+"-"+indate;
                                  String outtime = "-out-"+nextline.substring(posts+24, posts+35);
                                  if (inout.containsKey(key))
                                  {
                                      String val = inout.get(key);
                                      if (!(val.indexOf("out")&gt;0))
                                          inout.put(key, val+outtime);                    
                                  }
                                  else
                                      inout.put(key, outtime);
                              }
                          }
                      }
                      catch(Exception e)
                      {
                          System.err.println(nextline);
                          System.err.println(e.getMessage());
                      }
                      nextline = in.readLine();    
                  }
                  in.close();
  
                  for(String key: inout.keySet())
                  {
                      String val = inout.get(key);
                      out1.write(key+" , "+val+"\n");
                      System.out.println(key + val);
                  }
                  out1.close();
              }
          } 
          catch (IOException e)
          {
              throw new IllegalArgumentException(e);
          }
      }
  }
  </code></pre>
  
  <p>Description: These are log in and log out times of the employees,i am reading these from a log file ,but some are coming properly in single line like line 7 and line 8
                         and some are coming in different lines for same date,i want it to print in same line like example i have provided above,
                         and which ever records coming in single line both in and out time ishould retain it as it is....
                         PLZ CAN ANYBODY HELP ....!</p>