作者kusozack (hetun)
看板AndroidDev
标题Re: [问题] 2.3 json读取问题
时间Mon Dec 31 09:50:45 2012
※ 引述《Ferich (纯粹的透明)》之铭言:
: 因为使用的手机为 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有什麽样的问题呢?
你有看e跑什麽
--
Sent from my Android
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 223.141.177.135
1F:→ Ferich:感谢您回覆 已经解掉了 and 您用推文应该会比较好一点 12/31 14:25