import java.io.*; import java.util.Scanner; class StudentRecord { String ID; String name; String address; String level; } public class CreateStuFile2 { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); DataFile myFile = new DataFile("student-file"); // Open student-file StudentRecord x = new StudentRecord(); // Allocate buffer while ( true ) { System.out.print("Enter ID: "); x.ID = in.nextLine(); System.out.print("Enter name: "); x.name = in.nextLine(); System.out.print("Enter address: "); x.address = in.nextLine(); System.out.print("Enter level: "); x.level = in.nextLine(); myFile.WriteString( x.ID, 6 ); myFile.WriteString( x.name, 20 ); myFile.WriteString( x.address, 20 ); myFile.WriteString( x.level, 4 ); System.out.print("More ? (y/N) "); if ( ! "y".equals( in.nextLine() ) ) break; } } }