Http://blog.csdn.net/laorer/archive/2009/02/08/3868962.aspx
It solved a big problem. Thank you very much. Code-generated Java and JSP are no longer manually transcoded.
Core code:
Private Static void transferfile (string srcfilename, string destfilename) throws ioexception {
String line_separator = system. getproperty ("line. separator ");
Fileinputstream FCM = new fileinputstream (srcfilename );
Stringbuffer content = new stringbuffer ();
Datainputstream in = new datainputstream (FCM );
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 ();
FCM. Close ();
Writer ow = new outputstreamwriter (New fileoutputstream (destfilename), "UTF-8 ");
Ow. Write (content. tostring ());
Ow. Close ();
}
Convert a GBK encoded file into a UTF-8 encoded file
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/laorer/archive/2009/02/08/3868962.aspx