File Handling

Cards (9)

  • Before you do anything with a file you need to open it
  • To open a file, use an open command ( 'open()' ) and assign it to a variable
  • What is the name of the file that this code will open?
    file.txt
  • Some programming languages have separate modes for reading and writing - so they require you to say which mode you are in
  • You can create a new text file using the newFile command
  • After you have created a file , you still need to open the file using the open() command
  • After you have opened a file you can read or write to it
  • You can use the writeLine() command to write lines of text to a file
  • The writeLine() command will always write to the end of the text file