/********** Android 读取文件 中文 转码 ********/
BufferedReader bufferedReader = null;if (fileName.equals("/DoctorRecodeIOS.txt"))       //文件默认编码为ANSI    bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(downLoadFile), "GB2312"));else if (fileName.equals("/patientRecodeIOS.txt")) //文件默认为utf-8    bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(downLoadFile), "utf-8"));
 /*************2. 读取文件内容保存至fileContent***************/ while ((strReadLine = bufferedReader.readLine()) != null) {/*     String temp1 = EncodingUtils.getString(strReadLine.getBytes(),"GB2312");     String temp2 = EncodingUtils.getString(strReadLine.getBytes("utf-8"),"utf-8");     String temp3 = EncodingUtils.getString(strReadLine.getBytes(),"utf-8");*/     stringBuffer.append(strReadLine + "\n");     fileContent = new String(stringBuffer); }
   
//如果不识别 
EncodingUtils
builde gradule 中添加
dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {        exclude group: 'com.android.support', module: 'support-annotations'    })    compile 'com.android.support:appcompat-v7:25.3.1'    compile 'org.apache.httpcomponents:httpcore:4.4.4'  //识别 EncodingUtils    testCompile 'junit:junit:4.12'}

                                                                                               

更多相关文章

  1. android:获取网络时间、文件路径,修改包名,发布release版本
  2. Android文件列表RecyclerView中点击视频播放
  3. Android Dex文件结构
  4. android 文件存储注意点
  5. Android的动画配置xml文件
  6. android 打开文件
  7. Android--用SAX解析xml文件
  8. Android复制文件

随机推荐

  1. C#/mono开发Android应用程序入门(二)-第一
  2. 最强 Android(安卓)Studio 使用小技巧和
  3. Android(Kotlin版本)MVC框架的实例以及代码
  4. android lru缓存 辅助类LruCache源码解析
  5. Android与服务器交互
  6. Android(安卓)调试桥(adb)
  7. Android开发指南-三维图形
  8. Android(安卓)7 新特性浅析
  9. Android(安卓)修改系统屏幕亮度及监听
  10. Android(安卓)中报错 W/System.err: andr