Here is my code:
public boolean readFromFileBooking()
{
boolean isFileBooking = true;
try
{
BufferedReader reader = new BufferedReader(new FileReader("bookings.txt"));
String data = reader.readLine();
if (data == null)
{
System.out.println("No Bookings Have Been Made . . . .");
}
data = reader.readLine();
reader.close();
}
Here is the sequence:
- Write array into a text file
- Stop/exit from the system
- On restart load the previous array in the text file so it can be used again.
The problem is whenever I start a new system, the text file will be overwritten by a new array. Actually I want the new array become a new list in ArrayList.
Can you guys share to me how to load the previous data in a new system? How to load/copy the previous data in text file?
This will write out an array of integers into a file with each number separated by a space. It will then read them back in and store them as an arraylist. I have ignored the exception handling to focus on the IO.