我的 Java 程序使用Snake YAML来解析一个 YAML 文件,该文件包含要显示给用户的文本。其中一些字符串包含版权符号 (©)。当我在我的 IDE (IntelliJ IDEA) 中运行程序时,版权符号会正确呈现。但是,一旦我构建了一个工件并运行生成的 JAR 文件,版权符号就会改为呈现“©”(不带引号)。
如何更改我的程序以正确读取文件或更改 YAML 文件以便正确呈现版权符号?
这是加载 YAML 的 Java 代码。
private void loadOptions ()
throws IOException, SAXException, ParserConfigurationException
{
Yaml yaml = new Yaml();
String filePath = "./config.yml";
Reader reader = null;
try {
reader = new FileReader(filePath);
options = (Map<String, Map>) yaml.load(reader);
}
catch (FileNotFoundException e) {
String msg = "Either the YAML file could not be found or could not be read: " + e;
System.err.println(msg);
}
if (reader != null) {
reader.close();
}
}
以下是相关 YAML 代码的示例:
text:
copyright:
© 2007 Acme Publishing (info@example.org)