下面的代码是我目前拥有的代码,但它覆盖了当时csv文件中的所有数据,而不是将其附加到最后。是否有捷径可寻?
public void printCustomerList() throws IOException{
FileWriter pw = new FileWriter("F:\\data.csv");
Iterator s = customerIterator();
if (s.hasNext()==false){
System.out.println("Empty");
}
while(s.hasNext()){
Customer current = (Customer) s.next();
System.out.println(current.toString()+"\n");
pw.append(current.getName());
pw.append(",");
pw.append(current.getAddress());
pw.append("\n");
}
pw.flush();
pw.close();
}