作者Ferich (纯粹的透明)
看板AndroidDev
标题[问题] 2.3 json读取问题
时间Fri Dec 28 14:18:52 2012
因为使用的手机为 Android 4.0.4的版本
用了以下的code 来读取 在assets内的.txt (里面是json)
try{
InputStream in = getResources().getAssets().open(fileName);
int length = in.available();
byte [] buffer = new byte[length];
in.read(buffer);
res = EncodingUtils.getString(buffer, "UTF-8");
}catch(Exception e){
e.printStackTrace();
}
//openfile
String resok=res.replace("\n", "");
//json
try{
JSONObject presult = new JSONObject(resok);
......................
读取的方式大致是这样 fifleName="MapInfo.txt"
json格式也没有错 因为在手机上是可执行
主要是跟googlemap 结合 读取经纬度 在地图上标示出这些点的title
但是这个code 在 android 2.3.3 在跑到
JSONObject presult = new JSONObject(resok);
这一行 就跑到try/catch的catch去了
在debug模式下 有确认res 是有值的
请问有板友遇过这样的问题吗?
是2.3.3有什麽样的问题呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 1.34.130.81