java怎么读取文件中的json格式文件
发布网友
发布时间:2022-04-23 02:45
我来回答
共2个回答
热心网友
时间:2022-05-19 13:31
String fullFileName = "E:/a.json";
File file = new File(fullFileName);
Scanner scanner = null;
StringBuilder buffer = new StringBuilder();
try {
scanner = new Scanner(file, "utf-8");
while (scanner.hasNextLine()) {
buffer.append(scanner.nextLine());
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
} finally {
if (scanner != null) {
scanner.close();
}
}
System.out.println(buffer.toString());
这是读取文件的方法,至于解析json,则你自己弄吧
热心网友
时间:2022-05-19 14:49
有很多工具类的 json-lib.jar