8. File class Introduction It allows easy manipulation of files using the File class. Constructor File file: string mode: string Create an object of type File for the specified file. If mode is “r”, the file will be opened in read mode. If mode is “w”, the file will be opened in write mode. If the mode is “a”, the file will be open in append mode. Methods read byte int (1000) returns string Reads at most the specified number of bytes. When no numer is specified, 1000 bytes will be read at most. readLine returns string Reads untill end of line. write text: string Writes the specified text. WriteLine text: string Writes text with and end of line. close Closes the file. flush Flush all buffers to disk. eof returns boolean Returns true if the end of file has been reached. (static) methods and attributes Additionally, the File object has the following (static) methods and attributes: mkdir directory: string Creates the specified directory. stdin File Attribute that contains a File object associated with standard input. stdout File Attribute that contains a File object associated with standard output. stderr File Attribute that contains a File object associated with the standard error output. copy source: string target: string Copy selected file. This method is not able to copy directories. delete file: string Deletes a file or directory. move source: string target: string Moves (or renames) a file or directory. isDirectory f: string returns boolean Returns true if the specified file is a directory. canRead f: string returns boolean Returns true if the file can be read. canWrite f: string returns boolean Returns true if the file can be written. getParent f: string returns string Returns the parent directory of a file.