File Input and Output Chapter 14 Java Certification
- Slides: 8
File Input and Output Chapter 14 Java Certification by: Brian Spinnato
Text Representation of Character Encoding • Java uses two kinds – Unicode for internal representation of characters and strings – UTF for input and output • UTF is needed to represent all languages globally – Gives all the bits that a language needs – The compiler has to know which one
The File Class • See page 374 -378 for specific functions • Things to note: – Creates and instance of a file, NOT a file on the disk – To be of any use, it should contain a sting that is a name of a file – Path names can be entered ANY way, you must be aware of the OS your on – Constructing / Garbage collecting has no affect on the file system
Random Access File • Used to access non-standard files, the file that are incompatible with the stream/reader/writer model • Allows one to access any part of the file and read and write to it • Has two modes during construction – r: read only – rw: read and write
Streams, Readers, and Writers • The foundation of JAVA IO • View input and output as ordered sequences of bytes • Can be converted over to primitives, allowing one to “virtually” read in the primitives
Low-Level Streams • Low-level input streams have methods that read input and return inputs as bytes • Low-level output streams have methods that are passed bytes, and write the bytes as output • See page 383
High-Level Filter Streams • Allow the reading and writing of data types • High-level input streams do not read from input devices such as files or sockets, they read from other streams • High-level output devices do not write to output device, but to other streams • See page 385
Readers and Writers • Like input streams, low level communicate with I/O devices, the high level communicate with low level readers • ONLY use Unicode characters, not bytes • All extend from Reader super class • See page 390