Beispiel #1
0
 private void create() {
   try {
     Messaging.log("Creating file: " + this.file.getName());
     Files.createParentDirs(this.file);
     this.file.createNewFile();
   } catch (IOException ex) {
     Messaging.severe("Could not create file: " + this.file.getName());
     ex.printStackTrace();
   }
 }
Beispiel #2
0
 @Override
 public void save() {
   NBTOutputStream stream = null;
   try {
     Files.createParentDirs(this.file);
     final File temporaryFile =
         File.createTempFile(this.file.getName(), null, this.file.getParentFile());
     temporaryFile.deleteOnExit();
     stream = new NBTOutputStream(new FileOutputStream(temporaryFile));
     stream.writeTag(new CompoundTag(this.name, this.root));
     stream.close();
     this.file.delete();
     temporaryFile.renameTo(this.file);
     temporaryFile.delete();
   } catch (IOException ex) {
     ex.printStackTrace();
   } finally {
     try {
       stream.close();
     } catch (IOException ex2) {
     }
   }
 }