38 lines
1.0 KiB
Java
38 lines
1.0 KiB
Java
package tech.nevets.autoupdater;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonObject;
|
|
|
|
import java.io.File;
|
|
import java.io.FileReader;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
|
|
public class Config {
|
|
private JsonObject config;
|
|
|
|
public void loadFile() {
|
|
try {
|
|
File jsonFile = new File("./config.json");
|
|
if (!jsonFile.exists()) {
|
|
jsonFile.createNewFile();
|
|
FileWriter writer = new FileWriter(jsonFile);
|
|
writer.write("{ " +
|
|
"\"docker-socket\":\"unix:///var/run/docker.sock\", " +
|
|
"\"port\":8080" +
|
|
"\"verbose\":false" +
|
|
" }");
|
|
writer.close();
|
|
}
|
|
config = new Gson().fromJson(new FileReader(jsonFile), JsonObject.class);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public JsonObject getConfig() {
|
|
return config;
|
|
}
|
|
}
|