|
||
Lesson 5
Objective
|
Other sources of input and output streams Investigate input and output streams from files, network connections, and programs. |
|
|
Besides System.in and System.out,
the other sources of data in a Java program include files, network connections, and other programs.
Files
These other data sources are also provided as input or output streams.
Files, whatever their contents, are read and written through input and output streams.
Network connections
The java.io.FileInputStream class is used to read a file. The java.io.FileOutputStream class is used to write a file.
Network connections are also a fertile source of streams. When you connect to an Internet server, you read the data the server sends you via an
input stream, and you send data back to the server via an output stream.
Java Programs
Java programs themselves produce streams.
|
||
|
|
||
