修复加载配置文件异常的情况,catch后返回空字符串
This commit is contained in:
parent
ce7440f5b1
commit
86287dacf6
@ -32,12 +32,16 @@ public class ConfigTools {
|
|||||||
//System.out.println(type+"配置文件地址:"+file.getAbsolutePath());
|
//System.out.println(type+"配置文件地址:"+file.getAbsolutePath());
|
||||||
String src=readFile(file);
|
String src=readFile(file);
|
||||||
if(src!=null){
|
if(src!=null){
|
||||||
JSONObject json=JSONObject.parseObject(src);
|
try {
|
||||||
if(json==null){
|
JSONObject json=JSONObject.parseObject(src);
|
||||||
json=new JSONObject();
|
if(json==null){
|
||||||
saveFile(file,json.toJSONString());
|
json=new JSONObject();
|
||||||
|
saveFile(file,json.toJSONString());
|
||||||
|
}
|
||||||
|
return json.getOrDefault(key, "");
|
||||||
|
}catch (Exception e){
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return json.getOrDefault(key, "");
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user