Class WC

java.lang.Object
  |
  +--WC

public class WC
extends Object

Simulates the UNIX-command wc, ie counts characters, words and rows of a given file, or from standard in.
Usage: java WC []

Author:
Christian Liebchen
See Also:
main(String[])

Field Summary
private static int chars
          Counts the characters of the stream to be wc'd.
private static int rows
          Counts the rows of the stream to be wc'd.
private static int words
          Counts the words of the stream to be wc'd.
 
Constructor Summary
WC()
           
 
Method Summary
private static void evalRow(String row)
          Adds chars, words and the given row itself to our class variables.
static String formInt(int value)
          Just pretty, ie right aligned, outputting...
static void main(String[] args)
          Simulates the UNIX-command wc ignoring its options and allowing at most one input file.
private static void wcStream(InputStream is)
          Counts the characters, words, and rows of the given InputStream and prints them to System.out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chars

private static int chars
Counts the characters of the stream to be wc'd.


words

private static int words
Counts the words of the stream to be wc'd.


rows

private static int rows
Counts the rows of the stream to be wc'd.

Constructor Detail

WC

public WC()
Method Detail

evalRow

private static void evalRow(String row)
Adds chars, words and the given row itself to our class variables.

See Also:
chars, words, rows

formInt

public static String formInt(int value)
Just pretty, ie right aligned, outputting...


wcStream

private static void wcStream(InputStream is)
Counts the characters, words, and rows of the given InputStream and prints them to System.out.

See Also:
evalRow(String)

main

public static void main(String[] args)
Simulates the UNIX-command wc ignoring its options and allowing at most one input file.

Parameters:
args - IF args.length==0,
THEN read from System.in,
ELSE read from file args[0]
See Also:
man wc