【发布时间】:2013-05-05 00:40:33
【问题描述】:
我想将JSONObject 存储在一个文件中。
为此,我将对象转换为字符串,然后将其存储在文件中。
我使用的代码是:
String card_string = card_object.toString();
//card_object is the JSONObject that I want to store.
f = new File("/sdcard/myfolder/card3.Xcard");
//file 'f' is the file to which I want to store it.
FileWriter fw = new FileWriter(f);
fw.write(card_string);
fw.close();
代码按我的意愿工作。现在我想从文件中检索该对象。
我该怎么做?我对使用什么来读取文件感到困惑?
InputStream 或 FileReader 或 BufferedReader 或什么。我是 JAVA / android 开发新手。
请帮忙。欢迎使用简单的语言详细解释在不同场景(如此类)中使用哪些 I/O 功能。我查看了文档,但欢迎您提出建议。
【问题讨论】:
-
非常感谢您的回答。你也可以看看这些问题吗? stackoverflow.com/questions/16441330/… 和 stackoverflow.com/questions/16413498/…