| sykkn |
Nov 9th, 2004 10:43 PM |
it looks like you got two small errors. You forgot to put { after the second while, and you tried to call nextElement() on question, which is a String object, rather than the currentString StringTokenizer object.
:
import java.io.*;
import java.util.*;
public class token2
{
public static void main(String args[]) throws IOException{
String question;
StringTokenizer currentString;
BufferedReader InputData = new BufferedReader(new FileReader("c:/inputData.txt"));
while ((question = InputData.readLine()) != null){
currentString = new StringTokenizer(question,"?");
while (currentString.hasMoreElements()) {
System.out.println(currentString.nextElement());
}
}
}
}
|