using string tokenizer to separate items read in from text file
807569Sep 25 2006 — edited Sep 26 2006I have a text file with items in this format:
blue 78
red 34
green 90
I need to read in the file and then use string tokenizer to separate the words from the numbers so i can convert the numbers to int. How would I do this? This is what I have as far as inputting the file goes:
public static void main(String[] args)throws Exception
{
FileReader fr = new FileReader("C://file.txt");
BufferedReader br = new BufferedReader(fr);
String s;
StringTokenizer st = new StringTokenizer(s);
while((s = br.readLine()) != null)
{
System.out.println(s);
}
fr.close();
any help would be greatly appreciated