|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.unizh.ini.jaer.projects.robothead.WordCount
public class WordCount
Command line program to count lines, words and characters in files or from standard input, similar to the wc utility. Run like that: java WordCount FILE1 FILE2 ... or like that: java WordCount < FILENAME.
Field Summary | |
---|---|
int |
numChars
|
int |
numLines
|
int |
numWords
|
Constructor Summary | |
---|---|
WordCount()
|
Method Summary | |
---|---|
void |
count(java.lang.String fileName)
Open file, count its words, lines and characters and print them to standard output. |
void |
count(java.lang.String name,
java.io.BufferedReader in)
Count lines, words and characters in given input stream and print stream name and those numbers to standard output. |
void |
count(java.lang.String streamName,
java.io.InputStream input)
Count words, lines and characters of given input stream and print them to standard output. |
long |
countWords(java.lang.String line)
Determine the number of words in the argument line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int numLines
public int numWords
public int numChars
Constructor Detail |
---|
public WordCount()
Method Detail |
---|
public void count(java.lang.String name, java.io.BufferedReader in) throws java.io.IOException
name
- name of input sourcein
- stream to be processed
java.io.IOException
- if there were I/O errorspublic void count(java.lang.String fileName)
fileName
- name of file to be processedpublic void count(java.lang.String streamName, java.io.InputStream input)
streamName
- name of input stream (to print it to stdout)input
- InputStream to read frompublic long countWords(java.lang.String line)
line
- String to be examined, must be non-null
|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |