I am trying to Write new content to the file i've created but when i input some new values it deletes my last values and replace it with the new ones, Is there any way to keep putting new values and put that information in new lines of the file?
String line = "";
System.out.println( "Escriba el ID" );
CL.setID( reader.next() );
System.out.println( "Escriba el Presupuesto" );
CL.setPresupuesto( reader.next() );
System.out.println( "Escriba el Nombre del cliente" );
CL.setNombre( reader.next() );
try {
BufferedReader input = new BufferedReader( new FileReader( file ) );
Scanner input2 = new Scanner( file );
PrintWriter output = new PrintWriter( file );
output.println( "ID: #" + CL.getID() );
output.println( "Presupuesto: " + CL.getPresupuesto() + " $" );
output.println( "Nombre: " + CL.getNombre() );
output.println( line );
output.println( "----------------------------------------" );
output.close();
}
catch( IOException ex ) {
System.out.println( "Error!!!!" );
}
try {
Scanner input = new Scanner( file );
String ID = input.nextLine();
String c = input.nextLine();
String Name = input.nextLine();
System.out.printf( "%s \n%s$\n%s\n", ID, c, Name );
System.out.println( "Cliente Añadido exitosamente!!!" );
input.close();
}
catch( FileNotFoundException ex ) {
System.out.println( "ERROR!!!!!!!" );
}