android学习:自动识别文本文件编码格式
2014-04-06 17:01
232 查看
/** * 判断文件的编码格式 * @param fileName :file * @return 文件编码格式 * @throws Exception */ public static String codeString(String fileName) throws Exception{ BufferedInputStream bin = new BufferedInputStream( new FileInputStream(fileName)); int p = (bin.read() << 8) + bin.read(); String code = null; switch (p) { case 0xefbb: code = "UTF-8"; break; case 0xfffe: code = "Unicode"; break; case 0xfeff: code = "UTF-16BE"; break; default: code = "GBK"; } return code; }
有了这个函数,妈妈再也不用担心我的文本文件打开是乱码了,O(∩_∩)O哈哈~
相关文章推荐
- java自动识别用户上传的文本文件编码(未测试)
- java自动识别用户上传的文本文件编码
- java自动识别用户上传的文本文件编码
- 识别文本文件编码格式
- 20180129学习笔记之java获取文本文件编码格式
- 识别文本文件的编码
- Firefox - 附加软件 - Firebug - Console控制台视图 - console对象输出时,需要注意第一个参数被自动识别为格式字符串
- Android之UI学习篇五:AutoCompleteTextView自动完成输入内容
- 自动识别文字的编码以及读取所有文本——VB2005
- NET自动字符编码识别程序库 NChardet
- Android开发学习之路-指纹识别api初试
- Source Insight 4.0 文件类型、编码格式、tab转空格、tab键自动补全设置。。。(二)
- android 4.3 卡热插拔 自动识别卡类型
- [VB6]支持UTF文本文件访问的模块 支持UTF-8无BOM格式编码自动识别
- C#获取文本文件的编码,自动区分GB2312和UTF8
- 判断一个文本文件的编码格式
- Android自动识别短信验证码
- Android之UI学习篇五:AutoCompleteTextView自动完成输入内容
- 文本文件编码格式
- Source Insight 4.0 文件类型、编码格式、tab转空格、tab键自动补全设置。。。