title: Counting number of time the articles "a","an" are being used in a text file
body: <p>I'm trying to make a program that count the number of words, lines, sentences, and also the number of articles 'a', 'and','the'.
  So far I got the words, lines, sentences. But I have no idea who I am going to count the articles. How can a program make the difference between 'a' and 'and'.</p>
  
  <p>This my code so far.</p>
  
  <pre><code> public static void main(String[]args) throws FileNotFoundException, IOException        
      {       
  FileInputStream file= new FileInputStream("C:\\Users\\nlstudent\\Downloads\\text.txt");
  Scanner sfile = new Scanner(new File("C:\\Users\\nlstudent\\Downloads\\text.txt"));
  
    int ch,sentence=0,words = 0,chars = 0,lines = 0; 
  
    while((ch=file.read())!=-1)
    {
     if(ch=='?'||ch=='!'|| ch=='.')
      sentence++;
    }
  
      while(sfile.hasNextLine())  {
          lines++;
      String line = sfile.nextLine();
          chars += line.length();
          words += new StringTokenizer(line, " ,").countTokens();
      }
  
  
  System.out.println("Number of words: " + words);
  System.out.println("Number of sentence: " + sentence);
  System.out.println("Number of lines: " + lines);
  System.out.println("Number of characters: " + chars);
  }
  }
  </code></pre>