/** * 判断文件的编码格式 * @param fileName :file * @return 文件编码格式 * @throws Exception */ public stati ...
- /**
- * 判断文件的编码格式
- * @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;
- }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:关于文件读取时编码问题
关键词:编码
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。