Given that data.txt and alldata.txt are accessible, and the code fragment:
What is required at line n1 to enable the code to overwrite alldata.txt with data.txt?
Given that data.txt and alldata.txt are accessible, and the code fragment:
What is required at line n1 to enable the code to overwrite alldata.txt with data.txt?
To ensure that all data buffered in the BufferedWriter is written out to 'alldata.txt', the 'bw.flush()' method should be called. This method forces any buffered output bytes to be written out, which is critical for ensuring that the content read from 'data.txt' is fully written to the 'alldata.txt'. Therefore, writing 'bw.flush();' at line n1 will enable the code to overwrite 'alldata.txt' with 'data.txt'.
Correct answer is D
D is correct.
D is correct.
D tested