Write to a csv file with JSP without overwriting what you already have

0

I have this code below to write an information in the csv file, but every time I record something, what I have already written is lost. How do I add a line with the new information while retaining what I already have?

String fName = "cadastros.csv";
FileOutputStream fos = new FileOutputStream(fName);
PrintWriter pw = new PrintWriter(fos);
pw.println(request.getParameter("nome") + ";" + request.getParameter("email"));
pw.close();
fos.close();
    
asked by anonymous 01.06.2016 / 19:53

1 answer

0

Read the file in a string, add the new content in that string and then write the string with the old and new content.

    
01.06.2016 / 20:02