Class FlatFileItemWriter<T>

All Implemented Interfaces:
ResourceAwareItemWriterItemStream<T>, ItemStream, ItemStreamWriter<T>, ItemWriter<T>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

public class FlatFileItemWriter<T> extends AbstractFileItemWriter<T>
This class is an item writer that writes data to a file or stream. The writer also provides restart. The location of the output file is defined by a Resource and must represent a writable file.
Uses buffered writer to improve performance.
The implementation is not thread-safe.
Author:
Waseem Malik, Tomas Slanina, Robert Kasanicky, Dave Syer, Michael Minella, Mahmoud Ben Hassine, Stefano Cordio, Jimmy Praet
  • Field Details

  • Constructor Details

    • FlatFileItemWriter

      public FlatFileItemWriter(LineAggregator<T> lineAggregator)
      Create a new FlatFileItemWriter with the LineAggregator specified.
      Parameters:
      lineAggregator - to use to convert items to lines of text
      Since:
      6.0
    • FlatFileItemWriter

      public FlatFileItemWriter(org.springframework.core.io.WritableResource resource, LineAggregator<T> lineAggregator)
      Create a new FlatFileItemWriter with the WritableResource and LineAggregator specified.
      Parameters:
      resource - to write to
      lineAggregator - to use to convert items to lines of text
      Since:
      6.0
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Assert that mandatory properties (lineAggregator) are set.
      Throws:
      Exception
      See Also:
      • InitializingBean.afterPropertiesSet()
    • setLineAggregator

      @Deprecated(since="6.1", forRemoval=true) public void setLineAggregator(LineAggregator<T> lineAggregator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 6.1 in favor of passing the line aggregator to the constructor. Scheduled for removal in 7.0.
      Public setter for the LineAggregator. This will be used to translate the item into a line for output.
      Parameters:
      lineAggregator - the LineAggregator to set
    • doWrite

      public String doWrite(Chunk<? extends T> items)
      Description copied from class: AbstractFileItemWriter
      Write out a string of items followed by a "new line", where the format of the new line separator is determined by the underlying operating system.
      Specified by:
      doWrite in class AbstractFileItemWriter<T>
      Parameters:
      items - to be written
      Returns:
      written lines