首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

获取资料的编码方式

2012-08-22 
获取文件的编码方式public static String codeString(String fileName) throws Exception{BufferedInputSt

获取文件的编码方式

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;  }  

?

热点排行