我在使用Java写入文件时遇到问题.我想写入.txt文件,但是当程序写入任何内容时,它会在写入之前删除.我不想要它.我在使用flw.append之前使用了flw.write,但没有任何改变.你能帮助我吗 ?
public void list(String path) throws IOException {
FileWriter flw=new FileWriter(path);
flw.append("----------------------------------------------List---------------------------------------------\n");
for (int i = 0; i < athCtr - 1; i++) {
flw.append("Author:" + athr[i].getId() + "\t"
+ athr[i].getName() + "\t" + athr[i].getUniv() + "\t"
+ athr[i].getDepart() + "\t" + athr[i].getEmail()+"\n");
if (athr[i].getArtCtr() != 0) {
for (int j = 0; j < athr[i].getArtCtr(); j++) {
flw.append("+" + athr[i].getArticle(j) + ":");
for (int k = 0; k < artCtr; k++) {
if (art[k].getPaperId().equals(athr[i].getArticle(j))) {
flw.append("\t" + art[k].getName() …Run Code Online (Sandbox Code Playgroud)