I am reading a comma-delimited file that has two fields. The file may not contain a second field, so Spring DelimitedLineTokenizer should not complain when this happens. Stating the following
<property name="lineTokenizer"> <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"> <property name="names" value="planNumber, paymentAmount"> </property> <property name="delimiter"> <value>,</value> </property> </bean> </property>
Spring complains
Caused by: org.springframework.batch.item.file.transform.IncorrectTokenCountException: Incorrect number of tokens found in record: expected 2 actual 1 at org.springframework.batch.item.file.transform.AbstractLineTokenizer.tokenize(AbstractLineTokenizer.java:123) at org.springframework.batch.item.file.mapping.DefaultLineMapper.mapLine(DefaultLineMapper.java:46) ... 60 more
StringTokenizer will not complain though
source share