-1

create a new and unique file each time the function is compiled. that means if file exists already before execution of the program then it should delete the file and create a new file and append the new data. or add the content after just deleting the complete data which is already there in the same file.

I have created something like this....

Writer output = new BufferedWriter(new FileWriter("C:\\" + bankAccNo + ".txt", true));
output.append(myRow.getCell(0).toString()+ "\n");
output.close();
4

1 回答 1

1

如果您想在每次写入时覆盖文件内容,请使用falseappend 开关。

new FileWriter("<file>", false);
于 2012-04-21T06:13:11.237 回答