Files, File Reading, File Writing Flashcards

1
Q

where do computers store files

A

secondary devices eg hard disk, flash drives, DVDs etc

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

what is a byte-based stream

A

when input and output is in binary format

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

how many bytes in a characer

A

2

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

how many bytes in an int

A

4

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

how many bytes in a double

A

8

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

what is character based stream

A

output and input is a sequence of characters

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

example of character based stream

A

ASCII

Unicode

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

when would binary storage be used

A

images, videos

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

example of byte based file extensions

A

.jpeg

.png

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

example of character based file extensions

A

.txt

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

3 java input/output streams directly attached to console

A

system. in
system. out
system. err

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

can system.err be redirected? why might you want this?

A

yes

eg send to manufactures so they can debug and fix the problem

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

void write (byte[] arr) method in javaFileOutput stream does what

A

writes arr.length bytes from the bytes array to the output stream

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

how to write specific amounts from byte array

A

void write(byte[] array, int offset, int length)

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

how to write an individual byte in the array

A

voif write(int b)

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

how to close the file

why

A

name.close();

nothing will we written until its closed

17
Q

convert the string myString to a byte array

A

byte [ ] byteArray = myString.getBytes( );

18
Q

what does the function getBytes( ) allow us to do

A

get the string as a sequence of bytes

19
Q

getBytes is a fucntion within what class

A

fileOutput stream

20
Q

what is java file input stream used for

A

read from a file

21
Q

what does int read() method in the file input stream do

A

returns the number of bytes that were read from the input file

22
Q

how to read up to b.length bytes of data from file input stream

A

iint read(byte [ ] b);

23
Q

how to read a certain length of bytes from a file input stream

A

int read( byte [] b, int offset, int length)

24
Q

how to know when file has finished being read

A

will return -1

25
Q

what does buffered reader and writer allow

A

computer to continue to operate rather than hanging while waiting to read/write

26
Q

what must be passed into a buffered reader or writer

A

the file reader or writer

27
Q

what does the flush fucntion do in the buffered classes

A

forced out before we close the file

28
Q

instead of using file output class and converting the bytes to string ourselves, what can be used

A

file writer

29
Q

how to get name of file

A

file.getName();

30
Q

how to get absolute path of file

A

file,getAbsolutePath();

31
Q

how to get length of file

A

int file.length();

32
Q

how to make a new file

A

file file = new file (“”);