-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateRandFile.java
More file actions
36 lines (33 loc) · 937 Bytes
/
CreateRandFile.java
File metadata and controls
36 lines (33 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package Records_Combined;
/*
* This program creates a random access file sequentially by writing 100 empty records to disk.
*/
import java.io.*;
public class CreateRandFile {
private Record blank;
RandomAccessFile file;
public CreateRandFile() {
blank = new Record();
try {
file = new RandomAccessFile( "credit.dat", "rw" );
}
catch( IOException e ) {
System.err.println( "File not opened properly\n" +
e.toString() );
System.exit( 1 );
}
}
public void create() {
try {
for ( int i = 0; i < 100; i++ ) {
blank.write( file );
}}
catch ( IOException e ) {
System.err.println( e.toString() );
}
}
public static void main( String args[] ) {
CreateRandFile accounts = new CreateRandFile();
accounts.create();
}
}