The document outlines modifications to code for an ATM manager application. It instructs to:
1. Modify classes to read bank account data from files instead of arrays.
2. Create a new class to populate bank account files by reading details from another file.
3. Write all bank account addresses from an array to a separate address file.
It also provides code samples for writing and reading serializable objects to and from files.
The document outlines modifications to code for an ATM manager application. It instructs to:
1. Modify classes to read bank account data from files instead of arrays.
2. Create a new class to populate bank account files by reading details from another file.
3. Write all bank account addresses from an array to a separate address file.
It also provides code samples for writing and reading serializable objects to and from files.
The document outlines modifications to code for an ATM manager application. It instructs to:
1. Modify classes to read bank account data from files instead of arrays.
2. Create a new class to populate bank account files by reading details from another file.
3. Write all bank account addresses from an array to a separate address file.
It also provides code samples for writing and reading serializable objects to and from files.
The document outlines modifications to code for an ATM manager application. It instructs to:
1. Modify classes to read bank account data from files instead of arrays.
2. Create a new class to populate bank account files by reading details from another file.
3. Write all bank account addresses from an array to a separate address file.
It also provides code samples for writing and reading serializable objects to and from files.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 1
Lab 5
1. Modify the DataSetReader class to read BankAccounts from a file
bankAccountFile. 2. Modify the code in ATMManager to read the BankAccounts from a file. (You can use the code in DataSetReader class for this). 3. Create a class which will take input of BankAccount details from a file bankAccountDetailsFile and create the BankAccounts and save it in bankAccountFile. (After doing I/O in class). 4. Create a file addressFile. Write all the addresses of the BankAccounts from the array into the file addressFile.
Writing and reading objects from a file:
Object should be Serializable import java.io.Serializable; public class BankAccount implements Serializable{} import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; try{ FileOutputStream fout = new FileOutputStream("c:\\BAFile"); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(bankaccount); oos.close(); System.out.println("Done"); }catch(Exception ex){ ex.printStackTrace(); }
For reading use readObject() method of the ObjectInputStream. This will
return an Object, you will have to cast it before use.