Android开发过程中一老碰到matlab读取txt文件中文文件时输出的是乱码,如何解决这个问题

Android读取本地json文件的方法(解决显示乱码问题)
作者:居后不争
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Android读取本地json文件的方法,结合实例形式对比分析了解决显示乱码问题的方法,需要的朋友可以参考下
本文实例讲述了Android读取本地json文件的方法。分享给大家供大家参考,具体如下:
1、读取本地JSON ,但是显示汉字乱码
public static String readLocalJson(Context context, String fileName){
String jsonString="";
String resultString="";
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(
context.getResources().getAssets().open(fileName)));
while ((jsonString=bufferedReader.readLine())!=null) {
resultString+=jsonS
} catch (Exception e) {
// TODO: handle exception
return resultS
2、读取本地JSON,显示汉字正确,txt文件设置时UTF-8,UNIX
public static String readLocalJson(Context context, String fileName){
String jsonString="";
String resultString="";
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 resultS
更多关于Android相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家Android程序设计有所帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具鍙?渶涓

我要回帖

更多关于 matlab读取txt文件 的文章

 

随机推荐