标签:
JSONBuilder可以向文件中写入写入json字符串。如下面的例子:
public class Test { public static void main(String args[]) throws IOException { File f = new File("d:" + File.separator + "test.txt"); FileWriter fw = new FileWriter(f); JSONBuilder builder = new JSONBuilder(fw); builder.object(); builder.key("Json"); builder.value("Hello, World!"); builder.endObject(); fw.flush(); fw.close(); } }
输出结果为:{"Json":"Hello, World!"}
标签:
原文地址:http://www.cnblogs.com/longshiyVip/p/4608130.html