激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频

Android讀取本地json文件的方法

時(shí)間:2024-07-06 22:46:52 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í)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)文章:

隱藏電腦文件的方法03-19

excel合并多個(gè)文件的方法05-27

壓縮視頻文件的方法03-20

配置本地路由的常見(jiàn)方法介紹03-03

Node.js如何響應Ajax的POST請求并且保存為JSON文件詳解03-29

iphone和電腦傳文件的方法03-21

word 恢復未保存文件的方法01-04

mac給文件夾加密的方法03-12

解決本地連接故障的三個(gè)方法03-06

激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频