File Handling Flashcards

1
Q

What is file handling?

A

How a program can access data and change data stored in an external file.

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

What’s a benefit of accessing external files?

A

Accessing external files make programs more useful and powerful.

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

What’s the first step to using a file?

A

To open it.

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

How can you open a file?

A

Using an open command and assigning it to a variable.

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

What is openRead?

A
  • will open the file in read mode

- means you can read data from the file into your program

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

What is openWrite?

A
  • will open the file in write mode

- allows you to write data from your program to the file

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

What happens once the file is opened?

A

The program will start reading or writing it from the beginning. As this happens the program keeps its place in the file. (like a cursor).

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

What happens once you’ve finished reading or writing to a file?

A

Should always close the file using close().

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

What happens if you forget to close an opened file?

A

Then the file can remain locked and prevent others from editing it.

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

How can you write lines of text to file once it’s opened?

A
  • using writeLine()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If he file contains text when you’re using writeLine what happens?

A

It’ll overwrite what is currently there.

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

Where is the writeLine command called in a program?

A

On the variable that stores the external file.

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

What will the writeLine do after it’s called?

A

Automatically move onto the next line.

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

You can read lines of text from a file using what?

A

readLine()

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

What does the command endOfFile() do?

A

It returns true when the ‘cursor’ is at the end of the file. It’s main use is to signify when a program should stop reading a file.

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