gpt4 book ai didi

java - 属性文件键中没有 "\"的空格字符

转载 作者:行者123 更新时间:2023-11-30 08:43:20 27 4
gpt4 key购买 nike

我读取属性文件:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com