Before session 10
Streams
Objectives:
When you finish this module, you will
- create, modify and delete files and folders, using the class
File; - write bytes to a file and read them back from the file, using
FileOutputStreamandFileInputStream; - write text data to a file and read them back from the file, using
OutputStreamWriterandInputStreamReader; - write text data to a file and read them back from the buffer, using
BufferedOutputStreamandBufferedInputStream; - write values of primitive data types to a file and read them back from the file, using
DataOutputStreamandDataInputStream.
The streams are used with exceptions. However, exceptions will be explained in details next week. Hereof, please add into the methods' signature the following two words - throws Exception.
Topics
- 10.1 Introduction
- 10.2 Streams
- 10.3 Text encoding
- 10.4 Stream buffering
- 10.5 Some tricks with streams
- 10.6 Input and output of primitive data types
- 10.7 Tasks
Cheat sheet
Alternative materials
- in English: H. Schildt. Java - The Complete Reference: Chapter: 13
- in Estonian: here
- in Russian: Г. Шилдт. Java 8. Полное руководство: Chapter: 13