修复加载配置文件异常的情况,catch后返回空字符串
This commit is contained in:
parent
ce7440f5b1
commit
86287dacf6
@ -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 "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user