Before session 10
Streams
Objectives:
After completing the session, a student can:
- create, modify and delete files and folders, using the class
File
; - write bytes to a file and read them back from the file, using
FileOutputStream
andFileInputStream
; - write text data to a file and read them back from the file, using
OutputStreamWriter
andInputStreamReader
; - write text data to a file and read them back from the buffer, using
BufferedOutputStream
andBufferedInputStream
; - write values of primitive data types to a file and read them back from the file, using
DataOutputStream
andDataInputStream
.
Streams are used together with exceptions. 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 Byte streams
- 10.3 Character streams
- 10.4 Buffered streams
- 10.5 Data streams
- 10.6 Some tricks with streams
- 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