我有一個像這樣的json數(shù)組[ {"submitted":"Bob","limit":0,"ID":123,"target":3}, {"submitted":"Kate","limit":500,"ID":3221,"target":2} ]我需要找到一種方法,如何在不覆蓋文件或?qū)⑺袃?nèi)容加載到內(nèi)存中的情況下將記錄插入到該文件中目前我正在這樣做 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
提交
取消