Propeties读写问题
以下是我的代码
import java.util.*;
import java.net.*;
import java.io.*;
class Property
{
public static void main(String[] args)
{
Properties props = new Properties();
URL url = ClassLoader.getSystemClassLoader().getResource(
"test.properties");
try {
File f = new File(url.getPath());
InputStream is = new FileInputStream(f);
props.load(is);
System.out.println(props.getProperty("xy"));
System.out.println(props.getProperty("xj"));
OutputStream out=new FileOutputStream(f);
props.store(out, "xy=yinxu");
out.close();
}
catch (Exception e)
{
System.err.print(e);
}
System.out.println(props.getProperty("xy"));
System.out.println(props.getProperty("yx"));
}
}
test.property文件如下 xy=xuyin
yx=yangxin
我要的打印结果是:xuyin
yangxin
yinxu
yangxin
可是结果是;#xy=yinxu
#Thu Aug 12 16:31:07 CST 2004
yx=yangxin
xy=xuyin
怎么会得到这样的结果?请问应该怎样改才能得到我要的结果?