import java.io.IOException; import java.io.RandomAccessFile; public class CreateRandomFile { private static final int NUMBER_RECORDS = 100; // enable user to select file to open public void createFile() { RandomAccessFile file = null; try { // open file for reading and writing file = new RandomAccessFile( "clients.dat", "rw" ); AccountRecord blankRecord = new AccountRecord(); // write 100 blank records for (int count = 0; count < NUMBER_RECORDS; count++) blankRecord.write( file ); // display message that file was created System.out.println( "Created file clients.dat." ); } catch (IOException ioException) { System.err.println( "Error processing file." ); System.exit( 1 ); } finally { try { if (file != null) file.close(); // close file } catch ( IOException ioException ) { System.err.println( "Error closing file." ); System.exit( 1 ); } } } }