|
|
Start of Tutorial > Start of Trail > Start of Lesson | Search |
The followingmainmethod for theCountclass opens aReaderon a file named on the command line and then callscountCharswith thatReader. You can use this application to runcountChars.The output of this program depends on what's in the file named on the command line. These platform-specific instructions show you how to run the application on a file namedimport java.io.*; public class Count { // ... countChars method omitted ... public static void main(String[] args) throws Exception { if (args.length >= 1) countChars(new FileReader(args[0])); else System.err.println("Usage: Count filename"); } }testingthat contains the following ASCII text and displays the results:Now that you've seen theIch bin ein Berliner. I am a jelly doughnut.countCharsmethod in action, the remainder of this lesson looks at the various components that make up the method and how they fit into the Java language.
|
|
Start of Tutorial > Start of Trail > Start of Lesson | Search |