Eclipse下java项目的GBK编码代码文件转换为UTF-8编码的实现代码

时间:2021-12-17 14:08:46
String srcDirPath = "D:\\work\\SVN\\Service";   
String utf8DirPath = "D:\\work\\SVN\\Service2";          
Collection<File> javaGbkFileCol =  FileUtils.listFiles(new File(srcDirPath), new String[]{"java"}, true);     
for (File javaGbkFile : javaGbkFileCol) {   
      String utf8FilePath = utf8DirPath+javaGbkFile.getAbsolutePath().substring(srcDirPath.length());   
      FileUtils.writeLines(new File(utf8FilePath), "UTF-8", FileUtils.readLines(javaGbkFile, "GBK"));          

}

引用库:commons-io-2.6.jar