写文件操作为什么在LINUX和WINDOWS下的结果会不一样?!!?
我的代码如下:
try
{
FileOutputStream fo = new FileOutputStream("/home/root/1");
fo.write("你好abc".getBytes());
fo.close();
}
catch (IOException e)
{
e.printStackTrace();
}
听说是系统字符集的问题,通过设置JAVA的系统属性可以解决,但我修改代码如下还是没有任何改变:
try
{
System.setProperty("file.encoding", "GBK");
System.setProperty("user.language", "zh");
Properties pro = System.getProperties();
pro.list(System.out); // <--输入的值显示系统属性已被改变
FileOutputStream fo = new FileOutputStream("/home/maxchou/1");
fo.write("你好abc".getBytes());
fo.close();
}
catch (IOException e)
{
e.printStackTrace();
}