Java Apache驼峰路由中未显示新行字符
我试图在apachecamel中附加行,并用新行分隔。这就是我正在尝试的:Java Apache驼峰路由中未显示新行字符,java,apache-camel,Java,Apache Camel,我试图在apachecamel中附加行,并用新行分隔。这就是我正在尝试的: .transform().simple("asda\n") .to("file:{{file.tempLocation}}?fileName=${header.csvFileName}.txt") .transform().simple("asda\n") .to("file:{{file.tempLocation}}?fileName=${heade
.transform().simple("asda\n")
.to("file:{{file.tempLocation}}?fileName=${header.csvFileName}.txt")
.transform().simple("asda\n")
.to("file:{{file.tempLocation}}?fileName=${header.csvFileName}.txt&fileExist=Append")
.transform().simple("asda\n")
.to("file:{{file.tempLocation}}?fileName=${header.csvFileName}.txt&fileExist=Append")
理想情况下,这应该是输出
asda
asda
asda
但是我得到了asdaasda
,我不知道为什么
我尝试在notepad++中将行尾分隔符从CRLF改为LF,但也没有用。简单的解决方案是,您必须使用
transform().simple("asda\\n")
simple()
而不是constant()
\\n
代替\n
import org.apache.camel.builder.RouteBuilder;
公共类TimeDfLeapPenderRote扩展了RouteBuilder{
@凌驾
public void configure()引发异常{
从(“计时器:java?周期=1000”)
.routeId(“石英路线”)
.至(“直接:工作路线”);
从(“直接:工作路线”)
.routeId(“工作路线”)
.transform().simple(“128 Milyar Nerede!\\n”)
.log(“正文:.${Body}.”)
.to(“文件:输出/?文件名=test.txt&fileExist=Append”);
}
}
是否尝试使用.transform().constant(“asda\n”)
?是的。不起作用。此外,使用常量不能替代动态值。