コード例 #1
0
ファイル: Save.java プロジェクト: JonathanCMyers/Kungpow-Duck
 public Level1State read() {
   try {
     data = new byte[(int) file.length()];
     FileInputStream in = new FileInputStream(file);
     in.read(data);
     in.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
   Level1State l1s = Level1State.deserialize(data);
   return l1s;
 }
コード例 #2
0
ファイル: Save.java プロジェクト: JonathanCMyers/Kungpow-Duck
 public Save(String fileName) {
   try {
     // read something about java.utils.prefs.Preferences
     file = new File(fileName);
     if (!file.exists()) {
       FileOutputStream out = new FileOutputStream(fileName);
       out.close();
       System.out.println("file made");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
ファイル: Save.java プロジェクト: JonathanCMyers/Kungpow-Duck
 public void write(byte[] data) throws IOException {
   this.data = data;
   System.out.println(data.length);
   if (file.length() > 1000) {
     System.out.println("Exists");
     // Prompt user to overwrite the save file
     // Allow user to overwrite save file
   } else {
     try {
       FileOutputStream out = new FileOutputStream(file);
       out.write(data);
       out.close();
       // IOUtils.write(data, output);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }