7.3 Input and Output

Java relies on the notion of streams for doing input and output. A stream is essentially a series of bits sent from a source to a destination. It is a very useful abstraction of

The raw streams are in Java represented by the abstract classes InputStream and OutputStream. Concrete subclasses of these abstract classes offer various kinds of functionality, e.g. a BufferedInputStream will read ahead and keep the bits in a buffer. We will have a look at input and output for files in various formats, and also at loading URLs and images over the net. But first we will redo the echo-example to introduce the most basic streams.

Note that in this chapter all examples will be applications, not applets. This is because otherwise the Security Manager would interfere as soon as access to a disk is done.