java.lang.Object | +--WC
Simulates the UNIX-command wc, ie counts characters, words and
rows of a given file, or from standard in.
Usage: java WC [
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 |
private static int chars
private static int words
private static int rows
Constructor Detail |
public WC()
Method Detail |
private static void evalRow(String row)
chars
,
words
,
rows
public static String formInt(int value)
private static void wcStream(InputStream is)
InputStream
and prints them to System.out
.
evalRow(String)
public static void main(String[] args)
wc
ignoring its options
and allowing at most one input file.
args
- IF args.length==0
,System.in
,args[0]
man wc