我芦苇属性文件:
InputStream input = new FileInputStream("data.ini");
Reader reader = new InputStreamReader(input, Charset.forName("UTF-8"));
Properties prop = new Properties();
prop.load(reader);
我的属性文件Key
包含空格,我需要输入\
字符才能正确读取它。是否有可能不将 \
字符放入属性文件中并以正确的方式读取它?
属性文件内容:
aaa\ bbb=0
最佳答案
如 load 中所述Java文档:
The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=', ':', or white space character other than a line terminator.
所以答案是否定的。
通常键包含其他分隔符,我的经验是使用 '.'
。
aaa.bbb=0
关于java - 属性文件键中不含 "\"的空格字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34330037/