title: Loop through JAVA StringTokenizer
body: <p>please I need help badly. Thank You</p>
  
  <p>I read a text file from my hard disk which contains as follows....</p>
  
  <pre><code>void main()
  {
  
      int A = 5;
      int B = 5;
      int C ; 
      C = A + B;
      cout &lt;&lt; C ; 
  
  }
  </code></pre>
  
  <p>So, what I need to do is that..
  Lets say I have an array of...</p>
  
  <pre><code>String []KeyWord = {"void", "main()"};
  String []DataType = {"int", "float"};
  </code></pre>
  
  <p>So I want to loop through each token and check whether for example its a key word or a datatype. I used java netBeans and I code as follows </p>
  
  <pre><code>int k = 0; int l = 0;
  
  StringTokenizer Tokens;
  
  while ((CurrentLine = ReadFile.readLine()) != null)
  {
      Tokens = new StringTokenizer(CurrentLine, " ", true);
      for (int i = 0; Tokens.hasMoreTokens(); i++)
      {
          if (Tokens.nextToken().contains(KeyWord[k]))
          {
              jTextArea1.append(KeyWord[k] + "\n");
              k++;
          } 
          else if (Tokens.nextToken().contains(DataType[l]))
          {
              jTextArea2.append(DataType[l] + "\n");
          }
      } 
  } 
  </code></pre>