首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

为什么往Property后缀的文件里面写汉字会出现时乱码,读取出来也是乱码,英文汉字就是正常的解决思路

2012-03-28 
为什么往Property后缀的文件里面写汉字会出现时乱码,读取出来也是乱码,英文汉字就是正常的import java.uti

为什么往Property后缀的文件里面写汉字会出现时乱码,读取出来也是乱码,英文汉字就是正常的
import java.util.Properties;
import java.io.*;

public class Test2 {

public static void main(String[] args) {
System.out.println(System.getProperty("user.dir"));
File file = new File(System.getProperty("user.dir")+"/src/student.properties");
Properties p = new Properties();
Reader in =null;
try {
in = new FileReader(file);
BufferedReader br = new BufferedReader(in);
p.load(br);
System.out.println(p.getProperty("1.name"));
p.setProperty("3.name","QinSheng");
p.store(new FileOutputStream(file), null);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

[解决办法]
保存Unicode码不就行了
[解决办法]
peroperties.load(new InputStreamReader(new FileInputStream(file),"GBK"));
使用 InputStreamReader指定编码
[解决办法]

探讨
unicode怎么保存啊

[解决办法]
探讨
保存Unicode码不就行了

热点排行
Bad Request.