title: Can I use spring batch to read and send an entire text file at a time to the ItemProcessor?
body: <p>I have many text files, each with many lines, and all of the lines need to be processed together at the same time by an external process (smooks). How can I read the entire file into a <code>String</code> or <code>List&lt;String&gt;</code> (since there are line breaks) and send that in full to the <code>ItemProcessor</code>?</p>
  
  <p>I have tried to use</p>
  
  <pre><code>@Bean
  public ItemReader&lt;String&gt; reader() {
      FlatFileItemReader&lt;String&gt; reader = new FlatFileItemReader&lt;String&gt;();
      reader.setResource(new ClassPathResource("sample-data.csv"));
      reader.setLineMapper(new PassThroughLineMapper());
      return reader;
  }
  </code></pre>
  
  <p>but still each row in the file is sent to the <code>ItemProcessor</code> separately, which makes sense since that's very well defined in the documentation.  Am I trying to use spring batch in an unintended way?</p>
  
  <p>edit:</p>
  
  <p>I'm trying to work with </p>
  
  <pre><code>reader.setRecordSeparatorPolicy(new SimpleRecordSeparatorPolicy(){
      @Override
      public boolean isEndOfRecord(String line){
          if(line.contains("\u001a")){   // EOF character
              return true;
          }
          return false;
      }
     });
  </code></pre>
  
  <p>but the file does not contain an <code>EOF</code> character.  When I manually change the last line to include <code>"end"</code> and check for <code>line.contains("end")</code> then this works as expected and the entire contents gets sent to <code>ItemProcessor</code>.  I think I'm on the right track with some tweaking necessary but if someone has the best practice that'd be fantastic.</p>