Initial commit

This commit is contained in:
Zukero
2015-02-23 22:43:19 +01:00
commit 59d8ad1cdb
212 changed files with 29432 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
package com.gpl.rpg.atcontentstudio.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import com.gpl.rpg.atcontentstudio.Notification;
public class SettingsSave {
public static void saveInstance(Object obj, File f, String type) {
try {
FileOutputStream fos = new FileOutputStream(f);
try {
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
oos.flush();
oos.close();
Notification.addSuccess(type+" successfully saved.");
} catch (IOException e) {
e.printStackTrace();
Notification.addError(type+" saving error: "+e.getMessage());
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
Notification.addError(type+" saving error: "+e.getMessage());
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
Notification.addError(type+" saving error: "+e.getMessage());
}
}
public static Object loadInstance(File f, String type) {
FileInputStream fis;
Object result = null;
try {
fis = new FileInputStream(f);
ObjectInputStream ois;
try {
ois = new ObjectInputStream(fis);
try {
result = ois.readObject();
Notification.addSuccess(type+" successfully loaded.");
} catch (ClassNotFoundException e) {
e.printStackTrace();
Notification.addError(type+" loading error: "+e.getMessage());
} finally {
ois.close();
}
} catch (IOException e) {
e.printStackTrace();
Notification.addError(type+" loading error: "+e.getMessage());
} finally {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
Notification.addError(type+" loading error: "+e.getMessage());
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
Notification.addError(type+" loading error: "+e.getMessage());
}
return result;
}
}