Implementing the useDelimiter method
<p>I have the following code, please keep in mind I'm just starting to learn a language and a such have been looking for fairly simple exercises. Coding etiquette and critics welcome. </p>

<pre><code>import java.util.*;
import java.io.*;

public class Tron
{
    public static void main(String[] args) throws Exception
    {
        int x,z,y = 0;
        File Tron= new File("C:\\Java\\wordtest.txt");
        Scanner word = new Scanner(Tron);
        HashMap&lt;String, Integer&gt; Collection = new HashMap&lt;String, Integer&gt;();
        //noticed that hasNextLine and hasNext both work.....why one over the other?
        while (word.hasNext())
        {
            String s = word.next();
            Collection.get(s);
            if (Collection.containsKey(s))
            {
                Integer n = Collection.get(s);
                n = n+1;
                Collection.put(s,n);
                //why does n++ and n+1 give you different results
            }else
            {
                Collection.put(s,1);
            }       
        }
        System.out.println(Collection);


    }   
}
</code></pre>

<p>Without the use of <code>useDelimiter()</code> I get my desired output based on the file I have:</p>

<pre><code>Far = 2, ran = 4, Frog = 2, Far = 7, fast = 1, etc...
</code></pre>

<p>Inserting the <code>useDelimiter</code> method as follows </p>

<pre><code>Scanner word = new Scanner(Bible);
word.useDelimiter("\\p{Punct} \\p{Space}");
</code></pre>

<p>provides the following output as it appears in the text file shown below. </p>

<blockquote>
  <p>the the the the the</p>
  
  <p>frog frog </p>
  
  <p>ran</p>
  
  <p>ran ran ran</p>
  
  <p>fast, fast fast</p>
  
  <p>far, far, far far far far far</p>
</blockquote>

<p>Why such a difference in output if <code>useDelimiter</code> was supposed to account for punctuation new lines etc? Probably pretty simple but again first shot at a program. Thanks in advance for any advice. </p>
