Which code fragment correctly appends "Java 7" to the end of the file /tmp/msg.txt?

Which code fragment correctly appends “Java 7” to the end of the file /tmp/msg.txt?

Which code fragment correctly appends “Java 7” to the end of the file /tmp/msg.txt?

A.
FileWriter w = new FileWriter(“/tmp/msg.txt”, true); append(“Java 7”); close();

B.
FileWriter w = new FileWriter(“/tmp/msg.txt”, FileWriter.MODE_APPEND); append(“Java
7″); close();

C.
FileWriter w = new FileWriter(“/tmp/msg.txt”, Writer.MODE_APPEND); append(“Java 7”);
close();

D.
FileWriter w = new FileWriter(“/tmp/msg.txt”); append(“Java 7”); close();



Leave a Reply 2

Your email address will not be published. Required fields are marked *


bob

bob

“append” should be read “w.append” in every answer

bob

bob

and close -> w.close