springboot 获取resource下的json文件
/**
* 解析时间区间文件
* @return
*/
public JSONArray getFromJSONFile() {
JSONArray arry = null;
try {
Resource resource = new ClassPathResource("time-consum-interval.json");
JSONObject json = JSON.parseObject(IOUtils.toString(
new FileInputStream(resource.getFile()), Charsets.UTF_8.toString()));
arry = json.getJSONArray("level");
} catch (IOException e) {
e.printStackTrace();
}
return arry;
}