I have a program that adds people to arraylist. What I'm trying to do is add these persons to a text file, but the program overwrites the first line so that people are erased.
How to tell the compiler to write the next free line?
import java.io.*; import java.util.*; import javax.swing.JTextArea; public class Logic { File file; FileWriter fw; FileReader fr; BufferedWriter bw; ArrayList<Person> person; public Logic() { try { file = new File("register.txt"); if (!file.exists()) { file.createNewFile(); } } catch (IOException e) { } person = new ArrayList<Person>(); }
java overwrite line bufferedwriter
user1051477
source share