从 xsl 读取字符串时如何去掉 '\n' 字符?

How to get rid of the '\n' character while reading string from xsl?

我正在使用 XSLReader class 读取 xsl 文件,其中一列包含字符串,但有时该字符串已输入 (\n),因此当我读取并打印它时,我使用 \n:

打印字符串

这是两个地址,第一个在 xsl 字符串中输入,第二个没有...

VIALE SALVATORE REBECCHINI 39 \n00148 ROMA RM\n

viale castello della maglina,65-00148 roma 

有人提出了一些解决方案,但没有用,我不得不导入 common-lang3,它看起来像这样:

this.supplierAddress = StringEscapeUtils.escapeJava(info[19]);

它应该忽略 \n 但它没有..

有人吗?

谢谢!

你试过 :

replaceAll("\n","")

并且 escapeJava() 不是您需要的,您需要的是 unescapeJava() 但就像 javadoc 中所说的那样:

Unescapes any Java literals found in the String. For example, it will turn a sequence of '\' and 'n' into a newline character, unless the '\' is preceded by another '\'.