mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
|
@ -19,7 +19,7 @@ public class SaveObjectUtil {
|
|||
* Defines should data be saved or not.
|
||||
* Read from system property:
|
||||
*/
|
||||
private static boolean saveIncomeData = false;
|
||||
private static boolean saveIncomeData = false;
|
||||
|
||||
/**
|
||||
* Defines the system property name to get {@link #saveIncomeData} value from.
|
||||
|
|
@ -30,10 +30,10 @@ public class SaveObjectUtil {
|
|||
* Date pattern used to form filename to save object to.
|
||||
*/
|
||||
private static final String DATE_PATTERN = "[yyyy_MM_dd][H-mm-ss]";
|
||||
|
||||
static {
|
||||
saveIncomeData = System.getProperty(SAVE_DATA_PROPERTY) != null;
|
||||
}
|
||||
|
||||
static {
|
||||
saveIncomeData = System.getProperty(SAVE_DATA_PROPERTY) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save object on disk.
|
||||
|
|
@ -41,35 +41,35 @@ public class SaveObjectUtil {
|
|||
* @param object Object to save.
|
||||
* @param name Part of name that will be used to form original filename to save object to.
|
||||
*/
|
||||
public static void saveObject(Object object, String name) {
|
||||
if (saveIncomeData) {
|
||||
ObjectOutputStream oos = null;
|
||||
try {
|
||||
File dir = new File("income");
|
||||
if (!dir.exists() || dir.exists() && dir.isFile()) {
|
||||
boolean bCreated = dir.mkdir();
|
||||
if (!bCreated) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
String time = now(DATE_PATTERN);
|
||||
File f = new File("income" + File.separator + name + "_" + time + ".save");
|
||||
if (!f.exists()) {
|
||||
f.createNewFile();
|
||||
}
|
||||
oos = new ObjectOutputStream(new FileOutputStream(f));
|
||||
oos.writeObject(object);
|
||||
oos.close();
|
||||
public static void saveObject(Object object, String name) {
|
||||
if (saveIncomeData) {
|
||||
ObjectOutputStream oos = null;
|
||||
try {
|
||||
File dir = new File("income");
|
||||
if (!dir.exists() || dir.exists() && dir.isFile()) {
|
||||
boolean bCreated = dir.mkdir();
|
||||
if (!bCreated) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
String time = now(DATE_PATTERN);
|
||||
File f = new File("income" + File.separator + name + "_" + time + ".save");
|
||||
if (!f.exists()) {
|
||||
f.createNewFile();
|
||||
}
|
||||
oos = new ObjectOutputStream(new FileOutputStream(f));
|
||||
oos.writeObject(object);
|
||||
oos.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
return;
|
||||
} catch (IOException io) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String now(String dateFormat) {
|
||||
} catch (FileNotFoundException e) {
|
||||
return;
|
||||
} catch (IOException io) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String now(String dateFormat) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
||||
return sdf.format(cal.getTime());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue