Newb Question: passing objects in java?
- by Adam Outler
Hello, I am new at java. I am doing the following:
Read from file, then put data into a variable.
checkToken = lineToken.nextToken();
processlinetoken()
}
But then when I try to process it...
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.