修复加载配置文件异常的情况,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){
|
||||||
|
try {
|
||||||
JSONObject json=JSONObject.parseObject(src);
|
JSONObject json=JSONObject.parseObject(src);
|
||||||
if(json==null){
|
if(json==null){
|
||||||
json=new JSONObject();
|
json=new JSONObject();
|
||||||
saveFile(file,json.toJSONString());
|
saveFile(file,json.toJSONString());
|
||||||
}
|
}
|
||||||
return json.getOrDefault(key, "");
|
return json.getOrDefault(key, "");
|
||||||
|
}catch (Exception e){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user