Spring Batch - FlatFileParseException(用双引号记录) [英] Spring Batch - FlatFileParseException (record with double quotes)
问题描述
字段值之间的双引号记录很少.
I have few records with double quotes in between the field values.
所以当我使用 FlatFileItemReader 时,它会为这些记录抛出 FlatFileParseException.
So When i use FlatFileItemReader it throws FlatFileParseException for those records.
样本记录是:
7^A3989815^A2400284298^ABU^AA" - CLEANING INC.^A$
我们如何在 Spring Batch Item Readers 中处理此类记录?
How do we handle this kind of records in Spring Batch Item Readers?
问候,香卡
推荐答案
您可以将默认引号字符更改为您确定不会显示为建议的内容 此处.我们遇到了类似的问题,并按照建议将其更改为 @
并且它可以工作,但这会产生潜在的新问题,如果 @
出现它会中断.
You can change default quote character to something which you are sure will not appear as suggested here. We had similar problems and changed it to @
as suggested and it works, but that gives potentially new problem, if @
appears it will break.
其他解决方案是覆盖 DelimitedLineTokenizer
并始终按照建议从方法 isQuoteCharacter
返回 false
这里 这是更好的解决方案 IMO.
Other solution would be to override DelimitedLineTokenizer
and to always return false
from method isQuoteCharacter
as proposed here which is better solution IMO.
这篇关于Spring Batch - FlatFileParseException(用双引号记录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!