Java 将json文件转换为sd卡中的字符串
并在文本视图中打印它。因此,每次我运行应用程序时,如果文件夹存在于SD卡中,它就会从那里获取json,然后创建文件夹,我们手动将json插入其中。这就是我如何转换Java 将json文件转换为sd卡中的字符串,java,android,json,Java,Android,Json,并在文本视图中打印它。因此,每次我运行应用程序时,如果文件夹存在于SD卡中,它就会从那里获取json,然后创建文件夹,我们手动将json插入其中。这就是我如何转换字符串中的bottomText.json,该字符串位于SD卡的dor文件夹或/sdcard/dor/bottomText.json中,我使用TextView来显示它 FileReader inputStream = null; JSONObject obj1; try {
字符串中的bottomText.json
,该字符串位于SD卡的dor文件夹或/sdcard/dor/bottomText.json中,我使用TextView
来显示它
FileReader inputStream = null;
JSONObject obj1;
try {
String line,line1="";
String path;
File sdcard = Environment.getExternalStorageDirectory();
File f=new File(sdcard+"/dor");
f.mkdir();
File file1 = new File(sdcard,"/dor/fitness.json");
//file1.mkdir();
// Assuming each link to be on a new line
StringBuilder text = new StringBuilder();
String json1 = null;
try {
InputStream is1 = new FileInputStream(file1);
int size1 = is1.available();
byte[] buffer = new byte[size1];
is1.read(buffer);
is1.close();
json1 = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return;
}
TextView tv = (TextView)findViewById(R.id.textView);
tv.setText(json1);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请重新措辞你的问题。标题太长,令人困惑。我知道你们很兴奋,但请适当解释你们的帖子(问题/答案)。事实上,在我的回答中,wat-hav-done被转换成字符串bottomText.json,该字符串位于sdcard的dor文件夹或/sdcard/dor/bottomText.json中,我使用textview来显示它