Every time I write to the text file I will lose the original data, how can I read the file and enter the data in the empty line or the next line which is empty?
public void writeToFile()
{
try
{
output = new Formatter(myFile);
}
catch(SecurityException securityException)
{
System.err.println("Error creating file");
System.exit(1);
}
catch(FileNotFoundException fileNotFoundException)
{
System.err.println("Error creating file");
System.exit(1);
}
Scanner scanner = new Scanner (System.in);
String number = "";
String name = "";
System.out.println("Please enter number:");
number = scanner.next();
System.out.println("Please enter name:");
name = scanner.next();
output.format("%s,%s \r\n", number, name);
output.close();
}