转换程序出自:http://www.oschina.net/code/snippet_97118_11332
<span style="white-space:pre"> </span>/**
* 将制定目录下的所有Java源文件的编码格式从GBK修改为UTF-8
*/
public static void main(String[] args) throws Exception {
//GBK编码格式源码路径
String srcDirPath = "C:\\SOFT\\adt-bundle-windows-x86-20140624\\HomeWork\\src\\com\\qinhan\\library_3_0\\common";
//转为UTF-8编码格式源码路径
String utf8DirPath = "C:\\SOFT\\adt-bundle-windows-x86-20140624\\HomeWork\\src\\com\\qinhan\\library_3_0\\common\\new";
//获取所有java文件
Collection<File> 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"));
System.out.println("pipi1");
}
}
此贴留名,到此一游