//获取到文件编码格式
public static String codeString(String fileName) throws Exception {
File file=new File(fileName);
BufferedInputStream bin = new BufferedInputStream(new FileInputStream(file));
int p = (bin.read() << 8) + bin.read();
bin.close();
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;
}