title: StringTokenizer including whitespace
body: <pre><code>import java.util.*;
  
  public class test5 {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          String s = "hello=i am, the king of the world";
          int sum = 0;
  
          StringTokenizer t = new StringTokenizer(s, "=,;");
          while (t.hasMoreTokens()) {
              sum++;
              System.out.print(t.nextToken());
          }
  
          System.out.println("\n" + sum);
      }
  
  }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>helloi amthe king of the world 3</p>
  </blockquote>
  
  <p>No problem until about here.</p>
  
  <p>If I want to include some whitespace with these tokens, how would I do that?</p>
  
  <p>Changing:</p>
  
  <pre><code>StringTokenizer t = new StringTokenizer(s,"=,;");
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>StringTokenizer t=new StringTokenizer(s," =,;");
  </code></pre>
  
  <p>gives the output:</p>
  
  <blockquote>
    <p>helloiamthekingoftheworld 8</p>
  </blockquote>
  
  <p>It then overrides the other tokens.  How would I get both the whitespace and the desired tokens?</p>