title: Spring Batch: Reading a File : if field is empty setting the default value
body: <blockquote>
  <p>I am very new to spring batch. I have requirement in which i have to read a file having a header(Field Names) record and data records</p>
  <ol>
  <li><p>i have to validate 1st record (check the field names matching against set of predefined names)- note that this record need to be skipped- i mean should not be part of items in processor)</p>
  </li>
  <li><p>read and store rest of the field values to a POJO</p>
  </li>
  <li><p>if the field 'date' is empty , i need to set the default value as 'xxxx-yy-zz'</p>
  </li>
  </ol>
  <p>i am unable to 1st and 3rd requirement with batch
  here is the sample reader XML. please help</p>
  </blockquote>
  <pre><code> &lt;bean id=&quot;reader&quot; class=&quot;org.springframework.batch.item.file.FlatFileItemReader&quot;&gt;
       &lt;property name=&quot;resource&quot; value=&quot;classpath:input/import&quot; /&gt; 
       &lt;property name=&quot;encoding&quot; value=&quot;UTF-8&quot; /&gt;
      &lt;property name=&quot;linesToSkip&quot; value=&quot;1&quot; /&gt;
      &lt;property name=&quot;lineMapper&quot; ref=&quot;line.mapper&quot;/&gt;
   &lt;/bean&gt;
  
   &lt;bean id=&quot;line.mapper&quot; class=&quot;org.springframework.batch.item.file.mapping .DefaultLineMapper&quot;&gt;
      &lt;property name=&quot;lineTokenizer&quot; ref=&quot;line.tokenizer&quot;/&gt;
      &lt;property name=&quot;fieldSetMapper&quot; ref=&quot;fieldSet.enity.mapper&quot;/&gt;
   &lt;/bean&gt;
  
   &lt;bean id=&quot;line.tokenizer&quot; class=&quot;org.springframework.batch.item.file.transfo  rm.DelimitedLineTokenizer&quot;&gt;
       &lt;property name=&quot;delimiter&quot;&gt;
         &lt;util:constant static-field=&quot;org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer.DELIMITER_TAB&quot;/&gt;
       &lt;/property&gt;
       &lt;property name=&quot;names&quot; value=&quot;id,date,age &quot; /&gt;
       &lt;property name=&quot;strict&quot; value=&quot;false&quot;/&gt;
  &lt;/bean&gt;
  
    &lt;bean id=&quot;fieldSet.enity.mapper&quot; class=&quot;org.springframework.batch.item.file.mapping .BeanWrapperFieldSetMapper&quot;&gt;
        &lt;property name=&quot;targetType&quot; value=&quot;a.b.myPOJO&quot;/&gt;
        &lt;property name=&quot;customEditors&quot;&gt;
             &lt;map&gt;
                &lt;entry key=&quot;java.util.Date&quot;&gt;
                       &lt;bean class=&quot;org.springframework.beans.propertyeditors.C ustomDateEditor&quot;&gt;
                             &lt;constructor-arg&gt;
                                  &lt;bean class=&quot;java.text.SimpleDateFormat&quot;&gt;
                                           &lt;constructor-arg value=&quot;yyyy-mm-dd&quot; /&gt;
                                   &lt;/bean&gt;
                             &lt;/constructor-arg&gt;
                             &lt;constructor-arg value=&quot;true&quot; /&gt;
                       &lt;/bean&gt;
                 &lt;/entry&gt;
            &lt;/map&gt;
       &lt;/property&gt;
  </code></pre>