Choose correct writer

Report a typo

Fill in the gap in line 3 by creating an instance of FileWriter with name writer that uses sample.txt as a destination. Constructor should accept sampleFile object:

File sampleFile = new File("sample.txt");
String content = "Streams are easy!";
__;
writer.write(content);
writer.close();

Suppose sample.txt exists and has the following content: I don't think that.

The correct program should rewrite the existing content of the file by Streams are easy!.

Enter a short text
___

Create a free account to access the full topic