Otettu Path.of() käyttöön tiedostojen luvussa (käyttöjärjestelmä riippumattomuus)
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
package fi.lpam;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Main {
|
||||
public static boolean dev;
|
||||
public static Properties properties;
|
||||
|
||||
public static final File asetustiedosto = Path.of(SystemUtils.getUserHome().getAbsolutePath(), "OneDrive", "Kuljetusruokasovellus", "asetukset.properties").toFile();
|
||||
|
||||
static void main(String[] args) {
|
||||
//noinspection RedundantIfStatement
|
||||
if (args.length > 0) {
|
||||
@@ -17,13 +22,24 @@ public class Main {
|
||||
|
||||
try {
|
||||
properties = new Properties();
|
||||
properties.load(Main.class.getClassLoader().getResourceAsStream("app.properties"));
|
||||
properties.load(Main.class.getClassLoader().getResourceAsStream("defaults.properties"));
|
||||
properties.load(new FileInputStream(asetustiedosto));
|
||||
}
|
||||
catch (IOException e) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
properties.forEach((key, value) -> {
|
||||
System.out.println(key + ": " + value);
|
||||
});
|
||||
|
||||
App.main();
|
||||
|
||||
try (OutputStream os = new FileOutputStream(asetustiedosto)) {
|
||||
properties.store(os, "");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user