Java Input/Output  «Prev  Next»

Input, Output, and Java

You are already somewhat familiar with Java I/O through the use of the System.out object, which you have used to display text information on the screen. This module digs deeper into Java's support for I/O and shows you how to read and write information using special I/O objects called streams. You will also learn how to use streams to perform I/O on text files.

How was Input and Output achieved using Classic Streams in Java 1.1

In Java 1.1, input and output were achieved using the classes in the java.io package, such as InputStream and OutputStream for byte-based streams, and Reader and Writer for character-based streams. These classes provide methods for reading and writing data, and can be used to read from and write to various sources such as files, network sockets, and in-memory buffers. For example, to read from a file, you could use a FileInputStream object and call its read() method, and to write to a file, you could use a FileOutputStream object and call its write() method.

Module learning objectives

After completing the module, you will have the skills and knowledge necessary to:
  1. Understand the fundamentals of Java I/O
  2. Understand the importance of streams
  3. Read data from a stream
  4. Write data to a stream
  5. Work with text files