I have a text file that I am writing to. Each time I run the program the old data is erased. I need to be able to save and reopen the file.
The following is a code snippet
import java.io.*;
public class InputFile{
public static void main(String[] args)throws Exception
{
java.io.File file = new java.io.File("staff.txt");
java.io.PrintWriter output = new java.io.PrintWriter(file);
.....
......
System.out.println("Enter staff name \n");
String staffName = scan.nextLine();
System.out.println("Enter staff ID \n");
String staffID = scan.nextLine();
....
....
output.printf(staffName + staffID + ", ");
}
....
....
When the user inputs information it should save to text ad can be read later using BufferedReader.
Thanks
DRC