Page 515 - computer science (868) class 11
P. 515
97 }
98 else
99 System.out.println("File SUCCESSFULLY renamed");
100 break;
101 case 4:
102 mat1 = new DataInputStream(new FileInputStream("info.dat"));
103 std = new DataOutputStream(new FileOutputStream("temp.dat"));
104 eof = false;
105 while(!eof)
106 {
107 try
108 {
109 name = mat1.readUTF();
110 pan = mat1.readUTF();
111 taxIncome = mat1.readDouble();
112 String nam = name.toUpperCase();
113 std.writeUTF(name);
114 std.writeUTF(pan);
115 std.writeDouble(taxIncome);
116 }
117 catch(EOFException e)
118 {
119 System.out.println("This is end of File");
120 eof = true;
121 }
122 }
123 mat1.close();
124 std.close();
125 f1 = new File("info.dat");
126 f1.delete();
127 f2 = new File("temp.dat");
128 Rename = f2.renameTo(f1);
129 if(!Rename)
130 {
513
Sample Projects 513

