I am new at java. I am doing the following:
Read from file, then put data into a variable.
I have declared the checkToken and lineToken as public strings under the class.
public static void readFile(String fromFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fromFile));
String line = null;
while ((line=reader.readLine()) != null ) {
if (line.length() >= 2) {
StringTokenizer lineToken = new StringTokenizer (line);
checkToken = lineToken.nextToken();
processlinetoken()
......
But here's where I come into a problem.
public static void processlinetoken()
checkToken=lineToken.nextToken();
}
it fails out.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method nextToken() is undefined for the type String
at testread.getEngineLoad(testread.java:243)
at testread.readFile(testread.java:149)
at testread.main(testread.java:119)
so how do I get this to work? It seems to pass the variable, but nothing after the . works.
The Eclipse IDE is not much help "Link all references for a local rename (does not change references in other files)" Rename in file is the only option. It does not do anything.
lineTokenthat the methodprocesslinetoken()is calling is not aStringTokenizerbut aString. But it's hard to see.