Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Read File
- import java.io.FileInputStream;
- import java.io.ObjectInputStream;
- import java.io.IOException;
- import java.io.EOFException;
- public class ReadFile
- {
- private FileInputStream fis;
- private ObjectInputStream ois;
- private Record r;
- public ReadFile()
- {
- try
- {
- fis = new FileInputStream("Clients.ser");
- ois = new ObjectInputStream(fis);
- }
- catch(IOException ioe) { System.out.println("error"); }
- try
- {
- while(true)
- {
- //cast according to class Record
- r = (Record) ois.readObject();
- System.out.print(r.account + r.firstName + r.lastName + r.balance);
- }
- }
- catch(IOException ioe) { System.out.println("ioexception"); }
- catch(ClassNotFoundException cnfe) {System.out.println("classnotfound"); }
- }
- public static void main(String args[])
- {
- ReadFile rf = new ReadFile();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment