【发布时间】:2012-01-05 13:59:52
【问题描述】:
下面的代码是我目前拥有的,但是它会覆盖当时 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();
}
【问题讨论】: