title: StringTokenizer issues with if statements
body: <p>I have to tokenize a string which looks like this:<BR>
  <code>4830673048;Tony White</code><br>
  There must be two tokens separated by a <code>;</code><br>
  The first token must contain 10 digits, and ONLY digits<br>
  The second token may not contain digits.</p>
  
  <pre><code>  private static boolean isValid(String accountLine) throws BankAccountException
    {
       StringTokenizer strTok = new StringTokenizer(accountLine, ";");
       boolean valid = true;
       if(strTok.countTokens() == 2)
       {
          if(strTok.nextToken().length() == 10 &amp;&amp; strTok.nextToken().matches(".*[0-9].*"))
          {
             if(!strTok.nextToken().matches(".*[0-9].*"))
             {
                valid = true;
             }
          }
       }
       else
       {
          System.out.println("Invalid Bank Account info. " + strTok.nextToken());
          valid = false;
       }
       return valid;
    }
  </code></pre>
  
  <p>Here is the code I came up with, but it doesn't do what I expected it to do. I know the problem probably lies in my use of <code>.nextToken()</code>. So then my question is, what's the proper StringTokenizer method for ONLY checking the first or the second token?</p>