Parse FixedLength String with Apache Camel Bindy

Abhinav Gupta
1 min readApr 21, 2020

This article shows an example which helps in parsing a fixed-length string with Apache Camel Bindy.

What are we trying to achieve?

To convert a fixed-length string to Java Object. For example:

"101 OnePlus 7Pro 0010053000 INR "

Above fixed-length string give details for a mobile. Following lengths are defined for each parameter of the mobile object.

The expected output is:

Mobile [id=101 , brand=OnePlus , model=7Pro , numberOfPieces=100, price=53000.0, currency=INR ]

Code

  1. Create a class for mobile along with annotations required by Camel Bindy.

2. Main Logic

3. Gradle

4. Run the application. You should see the expected output.

--

--