Chapter 18: Files Flashcards
Describe the shift operators
> > signed right sheft: 1 shifted in left if number is negative
a «_space;b a shifted b bits left: 0s shifted in
> unsigned right shift: 0s shifted in
Describe integer bitwise operators
| Integer bitwise or is the same as addition when the numbers have no bits of the same value
* ^»_space; «_space; individually on bits
How do we read an input file into a program?
input file -> file input stream -> input stream reader -> buffered reader -> program
What makes up a file reader?
File input stream, input stream reader
How do we output to a file?
program -> print writer -> output stream writer -> file output stream -> output file
What makes up a file writer?
Output stream writer, file output stream
What is a print writer?
Wraps up output stream writer and provides println, printf, print etc. to print whole lines of text new printwriter(output stream writer).
Never throws exceptions! instead you have to use checkerror
What is a print stream?
subclass of output stream. Has print, println, printf and methods for writing bytes
What is an output stream?
Allows writing of bytes. Provides a view of data as byte stream. write() writes a byte given an int
What is an IO exception?
There is a lot that could go wrong when reading files. Most operations are capable of throwing exceptions.
A checked exception
What is an input stream?
provides a view of data as a sequence of bytes
What is an input stream reader?
When we wish to treat an input stream as a sequence of characters, we wrap it up in an input stream reader
What is a buffered reader?
Provides an instance method to read a whole line of characters in one go. Wraps up an input stream reader
What is a file input stream?
To read bytes from a file we use an instance of file input stream. A subclass of input stream
What is a file reader?
We can wrap a file input stream into file reader to read characters from a file
of we can wrap an input buffer to read a line of bytes
Has a input stream reader and is a input stream reader at the same time