我需要把一个很复杂的数据结构保存为JSON。
JSONArray jRecords=new JSONArray();
...
...
PrintWriter out = new PrintWriter(
new FileOutputStream(
Config.resultFolder+File.separator+"record.json"));
String str=jRecords.toString();
System.out.print(str);
out.print(str);
System.out.print可以正常输出,但是PrinterWriter的结果好像是后面的结果被砍掉了,不完整。是因为缓冲区不够大还是怎么样?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
是否忘记了
out.flush()
?