Hello Everybody,
I have a .csv file, in which details about emp-id, emp-name, emp-expenses for Reimbursement and email address are stored.
My application reads this .csv file, and sends a mail to each employee with his id, total expenses for Reimbursement details in text format.
TO calculate each employee's total, first i am storing each employee id in a hashtable, if id again occurs while reading the csv file, the value will be added to the previous data.
For time being,as the first step, i am just inserting values in to hashtable and trying to display it.
My Problem:
The loop is going into unlimited looping. hasMoreElements() is keepon incrementing even if there are only 4 values in enumeration.
code
-----------------------------------------------
try
{String s1="";
File f1 = new File(path);
FileInputStream fstream = new FileInputStream(f1); //new
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
Hashtable ht = new Hashtable();
int count=0;
while((s1=br.readLine())!=null )
{
count++;
out.println("Count= "+count);
StringTokenizer st = new StringTokenizer(s1,",");
if ((st.hasMoreTokens())&&(count>1))
{
String a=st.nextToken().trim();
String b=st.nextToken().trim();;
String c=st.nextToken().trim();;
String d=st.nextToken().trim();;
String e=st.nextToken().trim();;
String f=st.nextToken().trim();;
String g=st.nextToken().trim();;
String h=st.nextToken().trim();;
String i=st.nextToken().trim();;
String j=st.nextToken().trim();;
String k=st.nextToken().trim();;
String l=st.nextToken().trim();;
String m=st.nextToken().trim();;
String n=st.nextToken().trim();;
String o=st.nextToken().trim();;
String p=st.nextToken().trim();;
String q=st.nextToken().trim();;
String mail=st.nextToken().trim();;
String s=st.nextToken().trim();;
out.println("A= "+a+"b="+b+"c="+c+"d="+d+"e="+e+"f="+f+"mail="+mail);
ht.put("a",mail);
String show =(String)ht.get("a");
if (show != null)
{
out.println("HASHTABLE= " +a);
}
} //end of if
}//end of while
int iterate=0;while(em.hasMoreElements())
{
iterate++;
System.out.println("With in hasmore loop= "+iterate);//here, the loop is going into unlimited looping.Eventhough only 4 values of a is available
//out.println("Enum has more elements");
}
}catch(Exception e)
{out.println(e);}
-----------------------------------------------
Any help will be greatly appreciated.
Thanks in advance. :roll: