diff --git a/src/main/java/com/yutou/tools/utils/ConfigTools.java b/src/main/java/com/yutou/tools/utils/ConfigTools.java index 2838c80..f5b5d41 100644 --- a/src/main/java/com/yutou/tools/utils/ConfigTools.java +++ b/src/main/java/com/yutou/tools/utils/ConfigTools.java @@ -32,12 +32,16 @@ public class ConfigTools { //System.out.println(type+"配置文件地址:"+file.getAbsolutePath()); String src=readFile(file); if(src!=null){ - JSONObject json=JSONObject.parseObject(src); - if(json==null){ - json=new JSONObject(); - saveFile(file,json.toJSONString()); + try { + JSONObject json=JSONObject.parseObject(src); + if(json==null){ + json=new JSONObject(); + saveFile(file,json.toJSONString()); + } + return json.getOrDefault(key, ""); + }catch (Exception e){ + return ""; } - return json.getOrDefault(key, ""); } return ""; }