- Apr 17, 2004
- 17,555
- 1
- 0
Here's the part of the method I'm trying to get to work in my program:
Now here's the error I'm getting when I compile using JDK 1.5.0:
First of all, why can it not find nextToken??? I looked over the API and I think I'm using the right syntax, any ideas?
Second, I need to read the values from the file in as Strings, but then how am I supposed to check for end of file? Obviously the way I'm doing it up there doesn't work, what's another way to have the while loop repeat until end of file?
Thanks in advance guys
try {
FileReader fr = new FileReader(filename);
StreamTokenizer st = new StreamTokenizer(fr);
st.eolIsSignificant(false); //Allow tokenizing to continue until EOF
while((brstring = st.nextToken) != StreamTokenizer.TT_EOF)
{
brAddr = Integer.parseInt(brstring, 16); //Parse branch address into int
brtaken = st.nextToken; //Read t/f value
simulate_trace(brtaken, brAddr);
}
}
Now here's the error I'm getting when I compile using JDK 1.5.0:
brn_predictor.java:97: cannot find symbol
symbol : variable nextToken
location: class java.io.StreamTokenizer
while((brstring = st.nextToken) != StreamTokenizer.TT_EOF)
^
brn_predictor.java:97: operator != cannot be applied to java.lang.String,int
while((brstring = st.nextToken) != StreamTokenizer.TT_EOF)
^
brn_predictor.java:100: cannot find symbol
symbol : variable nextToken
location: class java.io.StreamTokenizer
brtaken = st.nextToken; //Read t/f value
First of all, why can it not find nextToken??? I looked over the API and I think I'm using the right syntax, any ideas?
Second, I need to read the values from the file in as Strings, but then how am I supposed to check for end of file? Obviously the way I'm doing it up there doesn't work, what's another way to have the while loop repeat until end of file?
Thanks in advance guys