/**
 * This class implements the 'wc' unix application.
 * @author fpereira
 */
public final class Wc {

  /**
   * Private ctor to avoid instantiation.
   */
  private Wc() {
  }

  /**
   * @param args
   *        The input line arguments.
   */
  public static void main(final String[] args) {
    if (args.length != 1) {
      System.err.println("Syntaxe: java Wc file");
      System.exit(1);
    } else {
      FileCopier2 fc = new FileCopier2();
      try {
        CharacterCounter cc = new CharacterCounter();
        fc.cp(new FileReader(args[0]), cc);
        WordCounter wc = new WordCounter();
        fc.cp(new FileReader(args[0]), wc);
        LineCounter lc = new LineCounter();
        fc.cp(new FileReader(args[0]), lc);
        System.out.println("\t" + lc.getNumLines() + "\t" + wc.getNumWords()
            + "\t" + cc.getNumCharacters() + "\t" + args[0]);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }

}
