![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 7
Rep Power: 0
![]() |
hi!i am trying to make a program that reads a whole file and then it prints the lines one by one.when i am trying to compile the program i am getting an error message that nextElement() symbol cannot be found.any ideas please?thank you!
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(question.nextElement());
}
}
} |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
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());
}
}
}
}
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2004
Posts: 7
Rep Power: 0
![]() |
worked!!!!thank you very very much!!!!!
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|