Java文件:尝试使用FileWriter将结果附加到已经存在的文件中
我试图使用与BufferedReader链接的FileWriter将结果附加到一个已经存在的文件中
String result = "";
StringBuffer sb = new StringBuffer();
result = sb.toString();
//After some processing, storing the result in the 'result' variable
System.out.println(result);
// outputting the result on the command prompt
// It is correctly showing me the result on the command prompt
try
{
FileWriter fw = new FileWriter("C:/Demo/SPCC/Assembly1.txt",true);
BufferedWriter out = new BufferedWriter(fw);
out.write(result);
// But, the above code fragment is not appending the result to the file
}
catch(Exception e)
{
System.out.println("Error");
}
// Thank you so much!
共 (0) 个答案