コード例 #1
0
 public static void save() {
   try {
     FileOutputStream bos = new FileOutputStream(new File(DataManager.getDirectory(), "database"));
     ObjectOutput out = new ObjectOutputStream(bos);
     out.writeObject(map);
     out.writeObject(perm);
     bos.close();
     out.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public static void load() {
   File f = new File(DataManager.getDirectory(), "database");
   try {
     if (!f.exists()) {
       f.getParentFile().mkdirs();
       f.createNewFile();
       save();
       return;
     }
     FileInputStream fis = new FileInputStream(f);
     ObjectInput in = new ObjectInputStream(fis);
     map = (HashMap<String, Object>) in.readObject();
     try {
       perm = (ArrayList<String>) in.readObject();
     } catch (Exception e) {
     }
     fis.close();
     in.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }