hi all,
i have a txt file like this:
gold dilver bronze
dept1 1.25 2.25 7,35
dept2 0.25 2.95 9,35
dept3 1.55 8.25 8,35
dept4 1.65 2.25 8,35
..........
...............
........
i have to read this file and find the avg of gold and silver and bronze.my coding part is like i used a
string tokeniser and read tokens but stuck with the current position.my coding:
import java.io.*;
import java.util.*;
public class formula
{
/* String rms=" ";
String rank=" ";
String n1=" ";
String n1eq=" ";*/
public static void main(String s[]) throws Exception
{
int ln=0;
String line=" ";String token="hi ";
BufferedReader b = new BufferedReader(new FileReader("sample.txt"));
LineNumberReader l = new LineNumberReader(b);
StringTokenizer st = new StringTokenizer(line);
while(true)
{
line = l.readLine();if (line==null) break;
ln = l.getLineNumber();
if (ln>=2)
{
System.out.println(line);
while (st.hasMoreTokens())
{
token = st.nextToken();System.out.println(token);
}
}
}
pls help me out.i am new to this and also suggest would it be better to use string tokeniser or stream tokeniser.
thanx in advance to one and all.