Eclipse GBK代码转移到UFT-8编码上去,迁移方案

方法一:(程序法)推荐
//用commons-io.jar实现文件的
//GBK编码格式源码路径 
String srcDirPath = "D:\\dev\\workspace\\masdev\\mas\\src"; 
//转为UTF-8编码格式源码路径 
String utf8DirPath = "D:\\UTF8\\src"; 
        
//获取所有java文件 
Collection javaGbkFileCol =  FileUtils.listFiles(new File(srcDirPath), new String[]{"java"}, true); 
        
for (File javaGbkFile : javaGbkFileCol) { 
      //UTF8格式文件路径 
      String utf8FilePath = utf8DirPath+javaGbkFile.getAbsolutePath().substring(srcDirPath.length()); 
       //使用GBK读取数据,然后用UTF-8写入数据 
      FileUtils.writeLines(new File(utf8FilePath), "UTF-8", FileUtils.readLines(javaGbkFile, "GBK"));        
}


方法二:(Eclipse文件转码插件法)
下载地址,百度网盘:http://pan.baidu.com/share/link?shareid=23599&uk=3573694317
 
step1. 将插件com.lifesting.tool.encoding_1.0.0.jar拷贝到eclipse/plugins目录下,重启Eclipse。

step2. 选择某个项目,右键选择properties,然后点击Convert Setting进行转码规则设置

你可能感兴趣的:(eclipse,编码,utf-8,gbk)