Home of real teaching & learning
  • Full support for teachers
  • Focus on critical thinking
  • Engaging classroom activities
  • Integrated student eBook
  • Assessed tasks / qBank
  • Practice exam questions

The InThinking Guarantee: Our sites are written by expert practitioners and not by AI

See our AI policy

Disclaimer: InThinking subject sites are neither endorsed by nor connected with the International Baccalaureate Organisation.

Don't miss out, find out!

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...

Help