I am trying to read a line from a file, then print only the first word in the line. It needs to do this until the end of the file.
The file is as follows:
Bib 0.9898 .iuiu k.kljlkj .98908
Joel .0909 .iuou k.iopi .jlkj
...
I need it to display as follows:
Bib
Joel...
Instead I am getting this:
Bib
Bibl
Biblj...
It keeps adding on to the first name instead of incrementing to the next line. Any suggestions would be great.
My snippet is as follows:
while ((strLine = br.readLine()) != null)
{
while(strLine.charAt(index) != ' ')
{
tmp += strLine.charAt(index++);
}
System.out.println (tmp);
}
Thanks for any help.