コード例 #1
0
 public void removeHallLoad(HallLoadPO hp) {
   try {
     FileInputStream fis = new FileInputStream("HallLoad.file");
     @SuppressWarnings("resource")
     ObjectInputStream ois = new ObjectInputStream(fis);
     @SuppressWarnings("unchecked")
     ArrayList<HallLoadPO> upl = (ArrayList<HallLoadPO>) ois.readObject();
     HallLoadPO a = null;
     for (HallLoadPO po : upl) {
       if (po.getIDOfHall().equals(hp.getIDOfHall())) {
         a = hp;
       }
     }
     upl.remove(a);
     FileOutputStream fs = new FileOutputStream("HallLoad.file");
     ObjectOutputStream os = new ObjectOutputStream(fs);
     os.writeObject(upl);
     os.close();
   } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #2
0
 public HallLoadPO getHallLoadPO(HallLoadPO hp) {
   try {
     FileInputStream fis = new FileInputStream("HallLoad.file");
     @SuppressWarnings("resource")
     ObjectInputStream ois = new ObjectInputStream(fis);
     @SuppressWarnings("unchecked")
     ArrayList<HallLoadPO> upl = (ArrayList<HallLoadPO>) ois.readObject();
     for (HallLoadPO po : upl) {
       if (po.getIDOfHall().equals(hp.getIDOfHall())) {
         return po;
       }
     }
     return null;
   } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }