title: String tokenizer to array java
body: <p>I'm trying to import data from a file to array using string tokenizer.</p>
  
  <p>Data format in file is</p>
  
  <pre><code>AA,BB,CC
  AA,BB,CC
  </code></pre>
  
  <p>But i keep getting error</p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
      at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
      at java.util.StringTokenizer.nextElement(StringTokenizer.java:407)
      at main.main(main.java:36)
  </code></pre>
  
  <hr>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  import java.util.StringTokenizer;
  
  
  public class main {
  public static void main(String[] args) throws FileNotFoundException {
  
      Scanner input;
      String line;
      int x=0;
      String [] cName = new String [100];
      String [] cMascot = new String [100];
      String [] cAlias = new String [100];
  
  
  
  
  
           input = new Scanner(new File("test.txt"));
  
           while(input.hasNextLine()) {
  
               line = input.nextLine();
               StringTokenizer strings = new StringTokenizer(line,",");
  
               while (strings.hasMoreElements()) {
                   cName[x] = strings.nextElement().toString();
                   cMascot[x] = strings.nextElement().toString();
                   cAlias[x] = strings.nextElement().toString();
                   x++;
               }
  
           }
  
  
  }
  
  }
  </code></pre>
  
  <p>So any help would be appreciated. I cant use array list so that out of the context</p>