为什么 fileToString 没有正确读取文件的内容?

Why is fileToString not reading the contents of the file properly?

我正在按照 CLAVIN 安装说明进行操作。当我尝试构建 CLAVIN 包时,它会在 TextUtilsTest 之后显示一个 'Build Failure',它检查从文件中提取的内容是否与预期的字符串完全相同。这是 TEST, and here's the method that reads contents from file 的代码。 这些是其失败背后的细节:

<failure message="wrong output from fileToString expected:&lt;Line1 word2[&#10;Line2 word2 word3]&#10;Line3&gt; but was:&lt;Line1 word2[&#10;Line2 word2 word3&#13;]&#10;Line3&gt;" type="org.junit.ComparisonFailure"><![CDATA[org.junit.ComparisonFailure: wrong output from fileToString expected:<Line1 word2[
Line2 word2 word3]
Line3> but was:<Line1 word2[
Line2 word2 word3
]
Line3>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at com.bericotech.clavin.util.TextUtilsTest.testFileToString(TextUtilsTest.java:56)
]]></failure>

我检查了输入文件,内容与提供的字符串完全一致。我怀疑问题是由于文本文件的编码引起的,我尝试了所有其他编码,但这只会让事情变得更糟。您是否建议我忽略异常,并继续进行下一个安装步骤?

出现意外 &#13; 或 CR,回车 return,\r。对于其余 &#10; 或 LF,\n 用作换行符。现在 Windows 使用 \r\n 作为换行符,所以可能在处理换行符时有些混乱。作为 Windows 上的文本区域,生成包含文本的 CR+LF,其中 LF 被删除,然后粘贴到仅 LF XML.

&#13; 是 XML 的数字实体。旧 MacOS 将 \r 作为换行符。)

解决方案是对仅 \n.

的多行输入文本进行一些行尾替换