亚洲中文日韩国产一区|亚洲国产精品原创巨作AV无遮挡|色依依国内精品中文字幕|日韩精品免费在线视频

<button id="lyzxa"><option id="lyzxa"><em id="lyzxa"></em></option></button>
    JSON

    Android讀取本地json文件的方法

    時(shí)間:2024-10-17 21:53:33 JSON 我要投稿
    • 相關(guān)推薦

    Android讀取本地json文件的方法

      本文實(shí)例講述了Android讀取本地json文件的方法。分享給大家供大家參考,具體如下:

      1、讀取本地JSON ,但是顯示漢字亂碼

      public static String readLocalJson(Context context, String fileName){ String jsonString=""; String resultString=""; try { BufferedReader bufferedReader=new BufferedReader(new InputStreamReader( context.getResources().getAssets().open(fileName))); while ((jsonString=bufferedReader.readLine())!=null) { resultString+=jsonString; } } catch (Exception e) { // TODO: handle exception } return resultString;}

      2、讀取本地JSON,顯示漢字正確,txt文件設(shè)置時(shí)UTF-8,UNIX

      public static String readLocalJson(Context context, String fileName){ String jsonString=""; String resultString=""; try { InputStream inputStream=context.getResources().getAssets().open(fileName); byte[] buffer=new byte[inputStream.available()]; inputStream.read(buffer); resultString=new String(buffer,"GB2312"); } catch (Exception e) { // TODO: handle exception } return resultString;}

    【Android讀取本地json文件的方法】相關(guān)文章:

    怎么打開xml文件的方法和軟件06-17

    MySQL導(dǎo)出導(dǎo)入SQL文件命令方法06-29

    ipad與電腦之間文件傳輸方法04-22

    在Word標(biāo)題欄顯示文件名的方法03-10

    配置顯示器顏色配置文件方法教程12-02

    電腦硬盤讀取不了怎么辦07-16

    用ISO鏡像文件安裝了Xp操作系統(tǒng)的方法教程07-22

    Fdisk無法讀取硬盤分區(qū)怎么辦07-16

    Word文件格式無效或文件已損壞怎么辦12-07

    勒索病毒文件恢復(fù)201707-16