Chapter 18: Files Flashcards

1
Q

Describe the shift operators

A

> > signed right sheft: 1 shifted in left if number is negative
a &laquo_space;b a shifted b bits left: 0s shifted in
> unsigned right shift: 0s shifted in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe integer bitwise operators

A

| Integer bitwise or is the same as addition when the numbers have no bits of the same value

* ^&raquo_space; &laquo_space; individually on bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we read an input file into a program?

A

input file -> file input stream -> input stream reader -> buffered reader -> program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What makes up a file reader?

A

File input stream, input stream reader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do we output to a file?

A

program -> print writer -> output stream writer -> file output stream -> output file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What makes up a file writer?

A

Output stream writer, file output stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a print writer?

A
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a print stream?

A

subclass of output stream. Has print, println, printf and methods for writing bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an output stream?

A

Allows writing of bytes. Provides a view of data as byte stream. write() writes a byte given an int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an IO exception?

A

There is a lot that could go wrong when reading files. Most operations are capable of throwing exceptions.
A checked exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an input stream?

A

provides a view of data as a sequence of bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an input stream reader?

A

When we wish to treat an input stream as a sequence of characters, we wrap it up in an input stream reader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a buffered reader?

A

Provides an instance method to read a whole line of characters in one go. Wraps up an input stream reader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a file input stream?

A

To read bytes from a file we use an instance of file input stream. A subclass of input stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a file reader?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an output stream writer?

A

We can wrap output stream in output stream writer to provide a view as a sequence of character instead of bytes

17
Q

What is a file output stream?

A

Writes bytes to a file

18
Q

What is a file writer?

A

File output stream can be wrapped in output stream writer to write character to file instead of bytes

19
Q

What does File allow us to do?

A

Examine properties of files e.g. exists()

20
Q

What is data output stream?

A
Allows us to write values of any primitive type to a file rather than writing bytes. 
Subclass of output stream
Instance of data output stream is a wrapper around an output stream
21
Q

What is data input stream?

A

Allows us to read values from a binary file that was written using data output stream
Subclass of inputstream
Wrapper around an input stream

22
Q

Give examples of input/output streams in the standard API

A

Err is an output stream
In is an input stream
Out is an output stream

23
Q

Describe assignment as an expression

A

= is an operator
it takes a variable as left operand and an expression as the right.
means we can write x = (y = 5) + (z = 3 + 4)
Right associative

24
Q

What is an initial value?

A

If you declare a variable but don’t give it a value, it is given a default initial value.