0

Currently I have a complex DTO which has an array in it like that:

 public class Dto {
       
        private String somethingObject;
        private List<String> arrayOfObjects;
}

I need to do a batch work on them, and I have the following file:

object | arrayItem1 arrayItem2 arrayItem3

I can use a LineTokenizer with a custom delimiter: "|" The problem is, that I can`t figure it out, how to recognize the fields in the array. I can change the structure of the input a little bit, it can be customized. I can change the List into Array as well, there is no restriction on that part.

The question is, that how can I force the ItemReader, that the arrayOfObjects is represented truly as a list with 3 elements, and not as a list with one long element like that : "arrayItem1 arrayItem2 arrayItem3"

  • what is/forgot the question? :) – xerx593 Aug 24 '22 at 15:05
  • The question is, that how can I force the ItemReader, that the arrayOfObjects is represented truly as a list with 3 elements, and not as a list with one long element like that : "arrayItem1 arrayItem2 arrayItem3" – Bence Ágocsi Kiss Aug 24 '22 at 19:33
  • i could deduce, but is really missing in the "OP", don't shy to [edit];) – xerx593 Aug 24 '22 at 19:50
  • ..but we have many options! – xerx593 Aug 24 '22 at 19:50
  • what means "I can change the structure of the input a little bit"? If it means: you are master of desaster/architect, then "why not JSON!?" (format + `JsonItemReader`) ..because that, what you have, is not really "flat"... – xerx593 Aug 24 '22 at 19:53
  • ..but of course you can implement a "very custom" (flat) file item reader (extending the existing ones, using custom/exisitng `LineMapper`s).. – xerx593 Aug 24 '22 at 19:56

0 Answers0