Newb Question: passing objects in java?

Posted by Adam Outler on Stack Overflow See other posts from Stack Overflow or by Adam Outler
Published on 2010-06-17T01:16:32Z Indexed on 2010/06/17 1:32 UTC
Read the original article Hit count: 319

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about objects