title: Java Program that takes a paragraph as input from user and prints number of delimiters (like \n, space, etc) on to the console
body: <p>Please help me out as i am not understanding how to count the space, new line etc.  i understand how to count the lines and words using space delimiter. how do i print the count of space, tab, \n etc? </p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  
  public class TextFileInfoPrinter
  {  
      public static void main(String[]args) throws FileNotFoundException        
      { 
          Scanner console = new Scanner(System.in);           
  
          System.out.println("File to be read: ");
          String inputFile = console.next();
  
          File file = new File(inputFile);
      Scanner in = new Scanner(file);
  
      int words = 0;
          int lines = 0;
          int chars = 0;
  
      while(in.hasNextLine())  {
              lines++;
              String line = in.nextLine();
              for(int i=0;i&lt;line.length();i++)
              {
                  if(line.charAt(i)!=' ' &amp;&amp; line.charAt(i)!='\n')
                  chars ++;
              }
              words += new StringTokenizer(line, " ,").countTokens();
      }
  
  
   System.out.println("Number of lines: " + lines);
   System.out.println("Number of words: " + words);
   System.out.println("Number of characters: " + chars);
      }
   }
  </code></pre>