Spring Batch中未终止的双引号 [英] Unterminated Double Quotes in Spring Batch
问题描述
我是Spring Batch的新手,我遇到了一个问题。
I am new to Spring Batch and I have run into a problem.
我正在处理的批处理应用程序从分隔的文本文件中读取和处理行。我已将应用程序配置为使用FlatFileReader来读取分隔的文本文件,但问题是正在读取的某些数据中包含双引号。当FlatFileReader遇到单个双引号时抛出FlatFileParseException,但是当存在两个双引号时不抛出。
The batch application I am working on reads and processes lines from a delimited text file. I have configured the application to use a FlatFileReader to read the delimited text file, but the issue is that some of the data being read has a double quote in it. A FlatFileParseException is thrown when the FlatFileReader encounters a single double quote, but none is thrown when two double quotes are present.
是否有人遇到此问题,如果有,什么是适当的解决方案?不幸的是,操纵数据本身并不是一种选择。我尝试在每个双引号之前添加一个转义字符,但无论如何都会抛出异常。
Has anyone come across this issue, and if so, what would be the proper resolution? Manipulating the data itself is not an option unfortunately. I have tried adding an escape character before every double quote, but an exception is still thrown regardless.
任何帮助都将不胜感激。
Any help would be greatly appreciated.
推荐答案
如果文件没有真正的引号(2x引号字符),你可以使用Spring论坛的解决方案更改DelimitedLineTokenizer的引用字符
if the files have no real quotes (2x quote character) you could go with the solution from the spring forum changing the quote character for the DelimitedLineTokenizer
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="quoteCharacter" value="@" />
</bean>
</property>
这篇关于Spring Batch中未终止的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!