IO Flashcards

(33 cards)

1
Q

What package use for input/output?

A

import java.io*

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

What buffering

A

Java will create intermediate memory called buffer which does reading and writing in the background. If not, then program would have to read one character at a time. This adds efficency

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

illustration of buffering

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

What is flushing?

A

force buffer to write to the file and wont return until its done. Ensures data is on the file before moving on

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

Byte streams are for what?

A

Bytes, for binary data. Good for non-text data

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

Explain character streams and what good for?

A

text files

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

What are the 3 predefined streams in java

A

system.in
system.out
system.err

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

Does JVM consider Console a byte device?

A

yes

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

Scanner is a common Console class. T/F?

A

yes

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

Scanner class.

A

import java.util.scanner

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

Intro to Files

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

T/F opening a file for writing will create a new file if it doesnt exist?

A

true

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

Writnig and updating files pic

A

close files after done to save space

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

What id buffered classes

A

wrapper class around i/o methods, to use buffer which adds efficeincy

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

why use try with resource statments

A

auto-close the file at exit of the try

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

Can you describe these byte stream wrappers?

19
Q

InputStream/outputstream topics

20
Q

fileinput/output stream

21
Q

bytearrayinputstream / output stream

A

treat bytes like a file

22
Q

bufferedinput/output stream

A

creates buffer support - usually perforamnce improvments

23
Q

explain pushbackinputstream

A

allows “unreading” read data. push byte back into the input stream buffer. Does not change underlying file.

does not have to pushback data you read

24
Q

whats printf()

A

specify format string then data

25
does printf lineup the columns?
yes... cool
26
datainputstream output
adds functionality
27
endless for-loop but traps when end of file exception... kinda cool
28
randomAccessFile explain
29
character stream topics
30
Reader/Writer classes
31
set up our parts inventory file so that the part number was contained in a field width of 8, the part name was contained in a field width of 15, and the part price was contained in a field width of 10 with two values after the decimal point.
output.printf( "%-8s %-15s %10.2f %n", "P-100", "PartNumber100", 5.25 ); output.printf( "%-8s %-15s %10.2f %n", "P-101", "PartNumber101", 2.10 ); The hyphen (-) in the string formats indicates that the respective objects will be left-justified in their respective fields. The %n in the format strings specifies that a line separator will be written
32
How write to file and append to the end of it?
PrintWriter output = new PrintWriter( new FileWriter( f, true) ); The “true” argument in the FileWriter constructor in the above statement allows data to be appended to the file.
33