【发布时间】:2018-08-30 22:38:10
【问题描述】:
我正在尝试从 Java 属性文件中读取 - 值,但它一直给我值 â 和类似 epsilon 的东西(粘贴时遇到问题)
我在逃避 " 时没有任何问题,但似乎无论我做什么 - 都会给我带来问题。我尝试了 '-' 和 \- 和 \\- 但似乎没有任何效果。
@Test
public void readFromProperties() throws IOException {
Properties options = new Properties();
FileInputStream in = new FileInputStream(Configs.optionsFi);
negComments.load(in);
in.close();
String option = options.getProperty("OPTION8");
System.out.println(negComment);
}
属性文件:
OPTION8=asdf asdf asdf asdf asdf – \"asdfasdf\"
System.out.println 结果:
asdf asdf asdf asdf asdf âepsilonlikething "asdfasdf"
【问题讨论】:
-
在您的示例中,
option等于好的字符串值,但 system.out.println 是一个奇怪的结果。但是,您在系统中打印的不是option,而是称为negComment的东西。这是为什么?它在哪里定义\创建?
标签: java character-encoding escaping properties-file