WC - Word Count Utility

In the Unix/Linux domain you always have the good-old wc utility to do word counting. In the Windows world things are differnet: too many times I found myself Googling something like "windows freeware wc". Here is a Java program that provides this elementy service of word-counting.

package wc;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main
{
   static int words = 0;
   static int lines = 0;
   static int chars = 0;
   
   public static void main(String[] args) throws FileNotFoundException
   {
      if(args.length == 0)
         go("stdin", new Scanner(System.in));
      else
      {
         for(String curr : args)
            go(curr, new Scanner(new File(curr)));
      }
      
      StringBuilder sb = new StringBuilder();
      for(int i = 0; i < 47; ++i)
         sb.append("-");
      System.out.println(sb);
      print("total", chars, words, lines);
   }

   private static void go(String fileName, Scanner scanner)
   {
      int ws = 0;
      int ls = 0;
      int cs = 0;
      
      while(scanner.hasNext())
      {
         String line = scanner.nextLine();
         ls += 1;
         cs += line.trim().length();
         
         StringTokenizer st = new StringTokenizer(line, " \r\n\t");
         while(st.hasMoreTokens()) 
         {
            ws += 1;
            st.nextToken();
         }
      }
      
      print(fileName, cs, ws, ls);
      
      lines += ls;
      words += ws;
      chars += cs;
   }

   private static void print(String fileName, int cs, int ws, int ls)
   {
      System.out.format("%20s %8d %8d %8d\n", fileName, cs, ws, ls);
   }
}