1. Eclipse Modify Settings
The configuration file was used in the project, so a new. Properties file was created in Eclipse, the Chinese was edited in the file, and the following error was reported when saving the eclipse:
Ways to solve this problem:
Select:
Menu-->preferences-->general-->contenttypes-->text-->javaproperties File, set default encoding, Change the following iso-8859-1 to UTF-8 or GBK (recommended UTF-8), and then update as shown.
2. Format conversion in Java code
After you perform the above steps, the file can be saved in UTF-8 format, but then there is a problem with it.
The code is as follows:
// Loading from the configuration file New Configuration ("Etc/orginfo.properties"); = Cfg.getvalue ("OrgName"); System.out.println ("pre-format" + _orgname);
The resulting output is: Before changing the format?? μ?-?? §????? ¤§?-|? ???? É?¢
To be sure, the file is formatted and converted somewhere after it has been read, but no reason has been found so far.
Therefore, the following modifications were made:
New Configuration ("Etc/orginfo.properties"); = Cfg.getvalue ("OrgName"); System.out.println ("pre-format" + _orgname); // encoding format conversion is required, otherwise it will be garbled New String (_orgname.getbytes ("iso-8859-1"), "Utf-8"); Orgname.setattribute ("value", cn_orgname);
The output at this time is:
Before you change the format?? μ?-?? §????? ¤§?-|? ???? É?¢
After the change of the format of University Hospital
This article was transferred from: http://blog.csdn.net/uestcong/article/details/6635123
Properties file encoding issues in eclipse