I am reading data from fixed length file.
This is file content:
Joe Smith Developer 075000 10012009
This is the mapping file:
<beanio>
<stream name="employeeFile" format="fixedlength">
<record name="employee" class="Employee" minOccurs="0" maxOccurs="unbounded">
<field name="firstName" length="10" />
<field name="lastName" length="10" />
<field name="title" length="10" />
<field name="salary" length="6" />
<field name="hireDate" format="MMddyy" minOccurs="0" length="unbounded" maxLength="8"/>
</record>
</stream>
</beanio>
output:
First Name:Joe
Last Name:Smith
Title:Developer
Salary:75000
Hire Date:Thu Oct 01 00:00:00 IST 2009
The code is reading the file and converting to pojo successfully. Now client needs strange requirement where I am struggling to implement.
From the file content "Joe Smith Developer 075000 10012009"
if the last values are not appearing or appearing partially still code should read the content successfully.
Eg: If the file has content like "Joe Smith Developer 0750"
. Here salary length is 4 but we declared as 6 in the mapping file and there is no hiredate data. Still, the code should read it successfully like it should take a salary as 0750 and hiredate as null.
How can I read this?