读取json文件

这里写自定义目录标题

  • 读取json文件

读取json文件

// 调用
public DocAndView gZipTest() throws Exception{String filePath = "D:\\WeChat Files\\WeChat Files\\wxid_txqcr4gdjmvs21\\FileStorage\\File\\2022-10\\svg.txt";String s = JarToPom.readJsonFile(filePath);Document document = JsonUtil.json2doc(s);return ViewUtil.getJsonView(document);}// 方法
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),"GB2312");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;}}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部