开发者

Spring batch - using multiple characters as delimiter

I have a input file with delimiter as "||".

As you can see there are two characters but batch accepts a single character as delimiter.

How to go about开发者_StackOverflow社区 this issue??

Issue Batch-591 in Jira shows as resolved -- Is it possible to use multiple characters as delimiter ??

Thanks, Nik


The referenced issue is resolved as wont-fix. This means they don't see the necessity of this issue.

But I guess you are recommended to implement your own Tokenizer class (probably extending AbstractLineTokenizer), using a workaround strategy like this one.


org.springframework.batch.item.file.transform.DelimitedLineTokenizer has two constructors :

DelimitedLineTokenizer() is the default constructor for the common case where the delimiter is a comma and is invoked automatically for a single character.

DelimitedLineTokenizer(java.lang.String delimiter) is used when the delimiter is of multiple characters.

Specify java.lang.String in constructor-arg type.


Hi Pete it really works for me I had to add this char "::" as a delimiter , this is the DelimitedLineTokenizer bean set up

<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
            <constructor-arg index="0" value= "::"/></bean>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜