Answer to Question #20638 in Java | JSP | JSF for nohra

Question #20638
When we open a file for appending and the file already exists
A) There is a compiler error
B) There is a runtime error
C) The file contents will be overwritten
D) We will be adding data at the end of the file
1
Expert's answer
2012-12-18T10:08:18-0500
this code appends "row" to a file. parameter "true" in "FileWriter(fileName, append)" constructor provides appending to existing file. if file does not exists, it creates this file.

public void writeIn(File file) throws IOException, ClassNotFoundException
{
String row="row";

PrintWriter out1 = new PrintWriter(new BufferedWriter(new FileWriter(file,true)));
&
out1.println(row);
out1.close();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS