I having a text file having records as below
name(1-3),age(4-5),ownCar(6)(if has put Y else leave blank)
Samples of data :
Dom32Y
Pat22
Sam23
Rob45Y
So here if you see each record is not of fixed length in size..So how can i read this text file using Spring Batch. Now i am reading this file using FixedLengthTokenizer , But i am getting error "Caused by: org.springframework.batch.item.file.transform.IncorrectLineLengthException"
I'm new to Spring Batch and Java Config. If someone can help me writing a solution for my problem i would really aprecciate it!
By default, the
FixedLengthTokenizer
works instrict
mode, meaning it will not tolerate a line with more or less tokens than expected. You can relax that by setting the strict flag to false, which will behave as follows:If that is not what you are looking for, you can override
FixedLengthTokenizer#doTokenize
and provide your custom logic.