import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author STUDES */ public class CreateSequentialFile { private ObjectOutputStream output; public void OpenFile() { try { output = new ObjectOutputStream(new FileOutputStream("client.ser")); } catch (IOException ex) { ex.printStackTrace(); } } public void addrecords() { AccountRecordSerializable record; int accountNumber = 0; String firstName; String lastName; double balance; Scanner input = new Scanner(System.in); System.out.printf("%s\n%s", "Enter account number (>0), firstname, lastname, balance", "?"); while (input.hasNext()) { accountNumber = input.nextInt(); firstName = input.next(); lastName = input.next(); balance = input.nextDouble(); if (accountNumber > 0) { record = new AccountRecordSerializable(accountNumber, firstName, lastName, balance); try { output.writeObject(record); } catch (IOException ex) { ex.printStackTrace(); } } else { System.out.println("accountNumber>0"); } } System.out.printf("%s\n%s", "Enter account number (>0), firstname, lastname, balance", "?"); } public void closeFile() { if (output != null) { try { output.close(); } catch (IOException ex) { } } } }