I read the records from the file and paste into the database.
I am using a DB2 database.
The entries are as follows:
abc pqr abcd
So, before abc there are several spaces at the beginning of the record.
I am reading the file using the SpringBatch program and inside the set mapper field I am printing the line read from the file:
System.out.println("*" + fieldSet.readString("FULL_RECORD") + "*");
However, I get the result:
*abc pqr abcd*
This means that leading spaces are not saved.
Linetokenizer in my configuration file:
<beans:property name="lineTokenizer">
<beans:bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<beans:property name="columns" value="1-241"/>
<beans:property name="names" value="FULL_RECORD"/>
</beans:bean>
</beans:property>
I use the mapper class by default and pass the tokenizer above as its property.
org.springframework.batch.item.file.mapping.DefaultLineMapper
How to keep leading spaces before each entry?
source
share