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

一个GBK编码的资料转成UTF8编码的文件

2012-10-12 
一个GBK编码的文件转成UTF8编码的文件private static void transferFile(String srcFileName, String dest

一个GBK编码的文件转成UTF8编码的文件

private static void transferFile(String srcFileName, String destFileName) throws IOException {  String line_separator = System.getProperty("line.separator");   FileInputStream fis = new FileInputStream(srcFileName);  StringBuffer content = new StringBuffer();  DataInputStream in = new DataInputStream(fis);  BufferedReader d = new BufferedReader(new InputStreamReader(in, "GBK"));// , "UTF-8"    String line = null;  while ((line = d.readLine()) != null)   content.append(line + line_separator);  d.close();  in.close();  fis.close();        Writer ow = new OutputStreamWriter(new FileOutputStream(destFileName), "utf-8");  ow.write(content.toString());  ow.close(); }

热点排行