File Handling Flashcards
Card 1 of 6
All 6 cards in this deck
What does
myFile.readLine()do?Returns the next line (record) in the open file.
What does
.writeLine()do?e.g.
myFile.writeLine("Sam")Writes a line (record) into the open file — adds
Samas a new line.What does
.endOfFile()return?True once the last record in the file has been read, otherwise false.
True or false? Data can be read from a file without opening the file first.
False. A file must be opened before reading or writing, and closed with
.close()afterwards.Why do programs store data in external files?
So data is kept after the program closes (e.g. a saved high score), and so the program can use data that isn't written into its own code.
Why should a file be closed with
.close()when a program has finished with it?Closing releases the file so other programs or users can open it and get the updated version. An unclosed file may stay locked.