This commit is contained in:
2020-10-18 20:48:23 +02:00
parent 16d5baabef
commit 93cbcb75a4

View File

@@ -31,25 +31,25 @@ public class GistProvider {
private String password; private String password;
private GistProvider() { private GistProvider() {
this.gistList = listAllGists();
readConfig(); readConfig();
this.gistList = listAllGists();
} }
private void readConfig() { private void readConfig() {
JSONParser jsonParser = new JSONParser(); JSONParser jsonParser = new JSONParser();
URL url = Resources.getResource("Gist_Config.json"); URL url = Resources.getResource("Gist_Config.json");
JSONObject gistConfig; JSONObject gistConfig = null;
try { try {
String jsonConfig = Resources.toString(url, StandardCharsets.UTF_8); String jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
//Read JSON file //Read JSON file
gistConfig = (JSONObject) jsonParser.parse(jsonConfig); gistConfig = (JSONObject) jsonParser.parse(jsonConfig);
this.username = gistConfig.get("username").toString();
this.password = gistConfig.get("password").toString();
} catch (IOException | ParseException e) { } catch (IOException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.username = gistConfig.get("username").toString();
this.password = gistConfig.get("password").toString();
} }
public static GistProvider getInstance() { public static GistProvider getInstance() {