2014-07-06 19 views
0

我想更新java中属性文件中的属性。但它正在为包含':'的字符串工作。例如,“C:\卡姆利什”写入“C \:\卡姆利什”码如下属性文件更新无法正常工作“:”

FileInputStream in = new FileInputStream("D:\\test\\prop.properties"); 
Properties props = new Properties(); 
props.load(in); 
in.close(); 

FileOutputStream out = new FileOutputStream("D:\\test\\prop.properties"); 
props.setProperty("filename", "C" +":" + "\\america"); 
props.store(out, null); 
out.close(); 

回答

3

的预期,因为:是(它可以被用来代替=)的隔板。所以它逃脱了。读取属性将自动忽略它。