Page 562 - Cs_withBlue_J_C11_Flipbook
P. 562
63 DataInputStream mat1 = new DataInputStream(new
FileInputStream("info.dat"));
64 DataOutputStream std = new DataOutputStream(new
FileOutputStream("temp.dat"));
65 boolean eof = false;
66 while(!eof)
67 {
68 try
69 {
70 name = mat1.readUTF();
71 pan = mat1.readUTF();
72 taxIncome = mat1.readDouble();
73 if(taxIncome>100000.0)
74 {
75 std.writeUTF(name);
76 std.writeUTF(pan);
77 std.writeDouble(taxIncome);
78 }
79
80 }
81 catch(EOFException e)
82 {
83 System.out.println("This is the end of File");
84 eof = true;
85 }
86 }
87 mat1.close();
88 std.close();
89 File f1 = new File("info.dat");
90 f1.delete();
91 File f2 = new File("temp.dat");
92 boolean Rename = f2.renameTo(f1);
93 if(!Rename)
94 {
95 System.out.println("ERROR: Cannot Rename File");
96 System.exit(0);
560560 Touchpad Computer Science-XI

