Apache Camel: How to remove header and footer from a fixed length file before splitting the file for processing?

110 Views Asked by At

I have a fixed length file in the following format:

Header
Line 1
Line 2
.
.
Line n
Footer

The requirement is, I need to read this file and process only its body, ignoring the header and footer. And since these files are going to be huge, I am splitting it to read n lines at once as follows:

from("file:/input")
.split(body().tokenize("\n", 1000, false)).streaming()
.unmarshal(fixedLengthFormat)
.process(myProcessor)
.to("file:/output?fileExist=Append")
.end();

I tried to add header, footer, skipHeader and skipFooter options in my @FixedLengthRecord model class for unmarshalling. Looks like first and last line of every split group is being excluded which is not what I'm expecting. Can you please let me know how I can ignore the very first and last lines of the whole file and not the first and last lines of every split group?

0

There are 0 best solutions below