Spring-Batch Multi-line record Item Writer with variable number of lines per record

后端 未结 3 1649
旧巷少年郎
旧巷少年郎 2020-12-09 06:56

I have the below requirement but am not able to decide on the approach to take:

I need to write data to a fixed format out put file where each record spans over mult

3条回答
  •  庸人自扰
    2020-12-09 07:31

    you can do it in CustomExtractor.

    for Example:

         public Object[] extract(T item) {
            List values = new ArrayList();
    
            BeanWrapper bw = new BeanWrapperImpl(item);
            for (String propertyName : this.names) {
                values.add( bw.getPropertyValue(propertyName) + "\r\n");
            }
            return values.toArray();
        }
    
        

    提交回复
    热议问题