reformat all code

This commit is contained in:
OMGeeky
2025-06-21 18:36:37 +02:00
parent bb187621b7
commit 90359bf285
120 changed files with 31732 additions and 31504 deletions

View File

@@ -1,76 +1,70 @@
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;
import java.io.*;
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;
}
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;
}
}