next up previous
Next: Reading from an input Up: Unit 09 Previous: Input streams

Output streams

Video

We use the predefined object System.out of the class PrintStream (subclass of OutputStream).

Example:

OutputStream os = System.out;

File

We create an object of the class FileOutputStream (subclass ofOutputStream) associated to the File object that identifies the file to open for writing.

Example:

FileOutputStream os = new FileOutputStream("data.txt");

Note: It is not possible to write to an Internet resource by simply using an output stream.


next up previous
Next: Reading from an input Up: Unit 09 Previous: Input streams