uto-generated catch block
e.printStackTrace();
}
try {
//使用第三方jar包检测文件的编码
Charset charset = detector.detectCodepage(inputStream, count);
if (charset != null) {
return charset.name();
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return defaultCharset;
}
public static void main(String[] args) throws Exception {
URL url = new URL("http://www.csdn.net");
System.out.println(CharsetUtil.getStreamCharset(url, "default"));
}
}
main函数运行结果如下:
ps:最近发现其他网站可能会对博客转载,上面并没有源链接,如想查看更多关于 基于lucene的案例开发 请点击这里。或访问网址www.2cto.com
|