コード例 #1
0
 public static void load() {
   if (DATAFILE.exists()) {
     try {
       mainData = CompressedStreamTools.readCompressed(new FileInputStream(DATAFILE));
     } catch (FileNotFoundException e) {
       OutputHandler.SOP("Failed in reading file: " + DATAFILE.getName());
       e.printStackTrace();
     } catch (IOException e) {
       OutputHandler.SOP("Failed in reading file: " + DATAFILE.getName());
       e.printStackTrace();
     }
   } else {
     mainData = new NBTTagCompound();
     save();
   }
 }
コード例 #2
0
  public static void save() {
    if (!DATAFILE.exists()) {
      DATAFILE.mkdirs();
    }

    File var1 = new File(ForgeEssentials.FEDIR, DATAFILENAME + "_tmp_.dat");
    try {
      CompressedStreamTools.writeCompressed(mainData, new FileOutputStream(var1));
    } catch (FileNotFoundException e) {
      OutputHandler.SOP("Failed in writing file: " + DATAFILE.getName());
      e.printStackTrace();
    } catch (IOException e) {
      OutputHandler.SOP("Failed in writing file: " + DATAFILE.getName());
      e.printStackTrace();
    }

    if (DATAFILE.exists()) {
      DATAFILE.delete();
    }

    var1.renameTo(DATAFILE);
  }