package com.gezi;
import com.alibaba.fastjson.JSON;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* 作者:是一个鸽子啊
* 时间:2020/06/07
*/
public class BoxJsonUtils {
//读取json文件
public static String readJsonFile(String fileName) {
String jsonStr = "";
try {
File jsonFile = new File(fileName);
FileReader fileReader = new FileReader(jsonFile);
Reader reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8");
int ch = 0;
StringBuffer sb = new StringBuffer();
while ((ch = reader.read()) != -1) {
sb.append((char) ch);
}
fileReader.close();
reader.close();
jsonStr = sb.toString();
return jsonStr;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
//json转List
public static List<Box> jsonBoxList(String jsonStr) {
List<Box> boxList=new ArrayList<>();
boxList = JSON.parseArray(jsonStr, Box.class);
return boxList;
}
public static List<Fly> jsonFlyList(String jsonStr) {
List<Fly> flyList=new ArrayList<>();
flyList = JSON.parseArray(jsonStr, Fly.class);
return flyList;
}
}
最近下载更多
lironggang LV38
2023年3月26日
最代码官方 LV168
2020年6月9日
最近浏览更多
lisansiwu LV2
7月14日
yimaoermao LV1
2024年11月28日
Boss绝 LV10
2024年7月1日
3334004690 LV11
2024年6月22日
lironggang LV38
2023年3月26日
libing1860
2022年5月30日
暂无贡献等级
murat7
2022年5月7日
暂无贡献等级
1057148049 LV11
2022年2月8日
woaini12788 LV7
2022年1月14日
my1999 LV2
2021年12月20日

