Given your mapping.xml
file, spaces will be used to pad the output when it is less than 6 digits long.
Using input of firstname = "Learner"
and salaray = 8888
, will produce the following output:
Learner 8888
There are 5 spaces in total between the end of the firstName (Learner
) and the start of the salary's first digit (8). The first 3 spaces are the padding for the firstName
field to make it of length 10. The next 2 spaces are the padding for the salaray
field. The spaces appear in front of the salaray
field because you specified that it should be right justified.
If you left it at the defaults, the salary
field would be left justified, the default for all fields without specifying the justify
attribute. Then the 2 spaces would be after the value of the salary
field.
To see it better, let us change the mapping.xml
file to use an asterisk (*) for padding the value of the firstName
field and use a zero (0) for padding the salary
field.
<stream name="employeeFile" format="fixedlength">
<record name="employee" class="example.Employee">
<field name="firstName" length="10" padding="*"/>
<field name="salary" length="6" justify="right" padding="0"/>
</record>
</stream>
This produces the following output:
Learner***008888