我有一个像这样的json数组[ {"submitted":"Bob","limit":0,"ID":123,"target":3}, {"submitted":"Kate","limit":500,"ID":3221,"target":2} ]我需要找到一种方法,如何在不覆盖文件或将所有内容加载到内存中的情况下将记录插入到该文件中目前我正在这样做 try (FileWriter file = new FileWriter("C:/test/output.json", true); BufferedWriter bfile = new BufferedWriter(file); PrintWriter outFile = new PrintWriter(bfile)) { outFile.write(obj.toJSONString()+System.lineSeparator()); outFile.flush(); } catch (IOException e) { e.printStackTrace(); }
添加回答
举报
0/150
提交
取消