title: Find how many times a word or phrase occurs in a document
body: <p>I am working on a GUI that reads in a file and searches it for how many times a word a phrase occurs. I got the code working when searching for individual words, but not phrases. I have posted the specific method for doing this below, can anyone help me?</p>
  
  <pre><code>public void run() {
      File f = new File("ARI Test.txt");
      try {
          Scanner scanner = new Scanner(f);
          while (scanner.hasNext())
          {
              String str = scanner.next();
              if (str.equals(word))
                  count++;
          }
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  textArea.append(word + " appears: " + count + " time(s)\n");
              }
          });
          scanner.close();
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
  }
  </code></pre>