Alas, finally set up-the project when the coding method for GBK, but with the continuous development of the final decision will be the code of the project to UTF-8, so that all the Java files containing Chinese have appeared garbled, hundreds of files ah, a change that still not exhausted, moved the brain, Write a piece of Java code, instant fix, the code is as follows:
package Com.ghj.packageofclient;import Java.io.file;import Java.util.collection;import org.apache.commons.io.FileUtils;/* * * Convert GBK encoded files to UTF-8 encoded format * * @author Gao Yingjie */public class GBKToUTF8 {public static void main (string[] args) throws Ex ception {String gbkdirpath = "D:\\SVNANDROID\\MEGREZMOBILE\\MEGREZLIB\\SRC";//GBK encoded format source file path String Utf8dirpath = "D:\\UTF8\\SRC";//Convert to UTF-8 encoded format source file save path @SuppressWarnings ("unchecked") collection<file> gbkfilelist = Fileutils.listfiles (new file (Gbkdirpath), new string[]{"Java"}, True);//Get all Java files for (file gbkfile:gbkfilelist) { String Utf8filepath = Utf8dirpath + gbkfile.getabsolutepath (). substring (Gbkdirpath.length ());//utf-8 encoded format File save path Fileu Tils.writelines (new file (Utf8filepath), "UTF-8", Fileutils.readlines (Gbkfile, "GBK"));//Use GBK encoded format to read files, Then write the data in UTF-8 encoded format}}}
This project relies on a jar package from Apache, so it is recommended to download the Java project directly.
"0-minute download demo"
How to use Java code to convert a GBK encoded format project to a UTF-8 encoded format