import java.io.*; Class RandomAcess1 int idno; String name; float sal; RandomAcessFile raf; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); RandomAcess1() { try{raf=new RandomAcessFile("emp.dat","rw"); }catch(Exception e) {System.out.prinntln((e);}} public void readEmp() { try{ System.out.println("enter the idno of employe"); idno=Integer.parseInt(br.readLine().trim()); System.out.pritnln("enter name"); name=br.readLine(); System.out.println("enter sal"); sal=float.parsefloat (br.readLine().trim()); }catch(Exception e) {System.out.println(e);}} public void writeFile() { String ch="yes"; try{ raf.seek(raf.length()); while(ch.equals("yes")); { readEmp(); raf.writeInt(Idno); raf.writeUTF(name); raf.writefloat(sal); System.out.println("any more rec's?"); ch=br.readLine().trim(); } readFile(); raf.close(); }catch(xception e) {System.out.println(e); } } pulic void readFile() { try{ raf.seek(0);
Ads