code: private static int count(final String needle, final String haystack) {
          int count = 0;
          int pos = -1;
          while ((pos = haystack.indexOf(needle, pos + 1)) >= 0) {
              count++;
          }
          return count;
      }
docs: Count the number of needles within a haystack.
  
  @param needle
  The string to search for.
  @param haystack
  The string to process.
  @return count of needles within a haystack