Streams and File I/O - Purdue University

Streams and File I/O

Chapter 9

Chapter 9

1

The Concept of a Stream

? Files can be used to store ? Java classes ? Java programs ? output from a program ? input for a program.

? File I/O as well as keyboard and screen I/O are handled by streams.

Chapter 9

6

The Concept of a Stream, cont.

? A stream is a flow of data (characters, numbers, etc.).

? Data flowing into a program is called an input stream.

? Data flowing out of a program is called an output stream.

Chapter 9

7

The Concept of a Stream, cont.

? A stream is implemented as an object.

? It delivers data to a destination such as a file or a stream or

? it takes data from a source such as a file or the keyboard, and delivers it to a program.

? System.out is the only output stream we have used so far.

? Objects of class Scanner, used for keyboard input, are streams, too.

Chapter 9

8

The Concept of a Stream, cont.

? This chapter discusses streams that connect programs to files.

Chapter 9

9

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download