SHARE
TWEET

Untitled

a guest Dec 2nd, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public boolean saveLevel() {
  2.         JumpIn j = new JumpIn(levelBeingBuilt);
  3.         if (isValidGame(j)) {
  4.             try {
  5.                 RandomAccessFile f = new RandomAccessFile(filePath, "rw");
  6.                 long length = f.length() - 1;
  7.                 byte b;
  8.                 do {
  9.                   length -= 1;
  10.                   f.seek(length);
  11.                   b = f.readByte();
  12.                 } while(b != 10);
  13.                 f.setLength(length+1);
  14.                 f.close();
  15.             } catch (Exception e) {
  16.             }
  17.                 File file = new File(filePath);
  18.                 String xml =  j.toXML() + "\n</Levels>";
  19.                 FileWriter writer;
  20.                 try {
  21.                     if(Play.fileIsEmpty(filePath)) {
  22.                         xml = "<Levels>\n" + xml;
  23.                     }
  24.                     writer = new FileWriter(file, true);
  25.                     writer.write(xml);
  26.                     writer.close();
  27.                 } catch (IOException e) {
  28.                     e.printStackTrace();
  29.                 }
  30.                 levelBeingBuilt.setLevel(levelBeingBuilt.getLevel()+1);
  31.                 return true;
  32.         }
  33.         return false;
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top