I'm trying to append lines to a report, but new lines are overwriting old ones.
Class with method main:
import java.io.FileNotFoundException;
public class TesteInscricoes {
public static void main(String[] args) throws FileNotFoundException {
Equipante gabriel = new Equipante();
gabriel.setNome("Gabriel");
Equipante milena = new Equipante();
milena.setNome("Milena");
InscricaoDeEquipante inscricaoDeEquipante = new InscricaoDeEquipante();
inscricaoDeEquipante.inscreveEquipantes(gabriel);
inscricaoDeEquipante.inscreveEquipantes(milena);
}
}
Enrollment class:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
public class InscricaoDeEquipante {
public void inscreveEquipantes(Equipante equipante) throws FileNotFoundException {
PrintWriter inscreve = new PrintWriter(new FileOutputStream(new File("Inscricoes.csv")), true);
inscreve.append(equipante.getNome());
inscreve.close();
}
}
At the end, the file only has the name "Milena".
I'm starting with java and I'm having difficulties with IO.
What do I need to use to get the expected result ??