Commit f05fea51 authored by HWliao's avatar HWliao Committed by klboke

文本文件编码探测,修改

探测不到编码不做处理 文件内容较少时,一般都不准确
parent fdf66b60
......@@ -169,7 +169,9 @@ public class DownloadUtils {
String encoding = null;
try {
FileCharsetDetector.Observer observer = FileCharsetDetector.guessFileEncoding(sourceFile);
encoding = observer.getEncoding();
// 为准确探测到编码,不适用猜测的编码
encoding = observer.isFound()?observer.getEncoding():null;
// 为准确探测到编码,可以考虑使用GBK 大部分文件都是windows系统产生的
} catch (IOException e) {
// 编码探测失败,
e.printStackTrace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment