Page 555 - ComputerScience_Class_11
P. 555

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);
                   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();






                                                                                                   Sample Projects  553
   550   551   552   553   554   555   556   557   558   559   560