[問題] 2.3 json讀取問題

看板AndroidDev作者 (純粹的透明)時間13年前 (2012/12/28 14:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
因為使用的手機為 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
文章代碼(AID): #1GtJdGFC (AndroidDev)
文章代碼(AID): #1GtJdGFC (AndroidDev)