public void readRaw(){
InputStream inputStream = getResources().openRawResource(R.raw.initdata);
//很有意思!配合name.setText(read(inputStream));方法只能被使用一次,接下来的再使用read(inputStream)将再也产生不了值, jsString 只有空 .
name.setText(read(inputStream));
String jsString = read(inputStream);
只能如下使用:
String jsString = (read(inputStream));
name.setText(jsString);
try {
JSONTokener jsonParser = new JSONTokener(jsString);
JSONObject person = (JSONObject) jsonParser.nextValue();
String HARDWARE_CODE = person.getString("HARDWARE_CODE");
String ZONE_NUMBER = person.getString("ZONE_NUMBER");
System.out.println("HARDWARE_CODE: " + HARDWARE_CODE + " ZONE_NUMBER"
+ ZONE_NUMBER);
} catch (JSONException ex) {
// 异常处理代码
ex.printStackTrace();
}
}
InputStream inputStream = getResources().openRawResource(R.raw.initdata);
//很有意思!配合name.setText(read(inputStream));方法只能被使用一次,接下来的再使用read(inputStream)将再也产生不了值, jsString 只有空 .
name.setText(read(inputStream));
String jsString = read(inputStream);
只能如下使用:
String jsString = (read(inputStream));
name.setText(jsString);
try {
JSONTokener jsonParser = new JSONTokener(jsString);
JSONObject person = (JSONObject) jsonParser.nextValue();
String HARDWARE_CODE = person.getString("HARDWARE_CODE");
String ZONE_NUMBER = person.getString("ZONE_NUMBER");
System.out.println("HARDWARE_CODE: " + HARDWARE_CODE + " ZONE_NUMBER"
+ ZONE_NUMBER);
} catch (JSONException ex) {
// 异常处理代码
ex.printStackTrace();
}
}