I am developing a college project that is a clinic system where the receptionist makes the patient's registration and other more options. I want to have the employee register a new patient, the form is saved with the patient's name individually. For each patient a new txt form saved. The code I'm doing, it's saving only in the file called Report, and the way it is it will always overlap the previous one. How do I make the individual entries with the name of each patient?:
public static void main(String[] args) throws IOException {
Scanner ler = new Scanner(System.in);
String nomeArq="Relatorio.pdf";
int i;
String nome;
String ender;
String email;
String tel;
String bairro;
String numero;
String exame;
File arquivo;
System.out.printf("Nome do paciente: ");
nome = ler.next();
System.out.printf("Endereço: ");
ender = ler.next();
System.out.printf("Bairro: ");
bairro = ler.next();
System.out.printf("Número: ");
numero = ler.next();
System.out.printf("Telefone: ");
tel = ler.next();
System.out.printf("E-mail: ");
email = ler.next();
System.out.printf("Exame: ");
exame = ler.next();
try
{
Formatter saida = new Formatter(nomeArq);
saida.format(" --- Ficha cadastral de pacientes ---");
saida.format('\n'+"Nome do paciente: "+nome);
saida.format('\n'+"Endereço: "+ender);
saida.format('\n'+"Bairro: "+bairro);
saida.format('\n'+"Numero: "+numero);
saida.format('\n'+"Email: "+email);
saida.format('\n'+"Telefone: "+tel);
saida.format('\n'+"Exame: "+exame);
saida.close();
System.out.println("Arquivo '"+nomeArq+"' Salvo com sucesso!");
}
//mostrando erro em caso se nao for possivel gerar arquivo
catch(Exception erro){
System.out.println("Arquivo nao pode ser gerado!");
}