title: Scanner class skips over whitespace
body: <p>I am using a nested <code>Scanner</code> loop to extract the digit from a string line (from a text file) as follows:</p>
  
  <pre><code>String str = testString;            
  Scanner scanner = new Scanner(str); 
  while (scanner.hasNext()) {
      String token = scanner.next();
      // Here each token will be used
  }
  </code></pre>
  
  <p>The problem is this code will skip all the spaces <code>" "</code>, but I also need to use those "spaces" too. So can <code>Scanner</code> return the spaces or I need to use something else?</p>
  
  <p>My text file could contain something like this:</p>
  
  <pre><code>0
  011
  abc
  d2d
  
  sdwq
  
  sda
  </code></pre>
  
  <p>Those blank lines contains 1 <code>" "</code> each, and those <code>" "</code> are what I need returned.</p>