The following application reads and counts characters in its input and then
displays the number of characters read. The character-counting program uses
several components of the Java language and of the class libraries shipped
with the Java development environment. The links in the following listing visit
pages that explain a particular feature of the application or a general Java
language concept. Where appropriate, those pages refer you to other lessons
in The Java Programmer's Guide or to other documentation.
class Count {
    public static void main(String args[])
        throws java.io.IOException
    {
        int count = 0;
        while (System.in.read() != -1)
            count++;
        System.out.println("Input has " + count + " chars.");
    }
}
Instead of using the links embedded in the source listing above,
you can use the
 and
and
 links (in the header and footer of each page) to step through the links in order.
links (in the header and footer of each page) to step through the links in order.