The code below is what I currently have, however it overwrites any data in the csv file at that time, instead of appending it to the end. Is there an easy way to do this?
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();
}
Try opening file like this
Pass
trueargument for appending.