B2.5 Visualising File Operations - Answers - Java
Task 1: The Logic Error Answer: In Java, FileWriter may hold data in a memory buffer and not write it to the actual disk file until close() or flush() is called. If we try to read the file with a Scanner before closing the writer, the file on the disk might still be empty (size 0 bytes), so the Scanner finds nothing. Also, unlike Python's w+ mode which allows read/write on the same handle, Java typically requires...