![]() ![]() ![]() |
Start of Tutorial > Start of Trail > Start of Lesson | Search |
The followingmain
method for theCount
class opens aReader
on a file named on the command line and then callscountChars
with 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"); } }testing
that contains the following ASCII text and displays the results:Now that you've seen theIch bin ein Berliner. I am a jelly doughnut.countChars
method 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 |