Hi,

I want to process a big file which looks like this:

:20:test1
:25:payment1
:75:FEES
$
:20:test2
:25:payment2
:75:FEES
$
:20:test3
:25:payment3
:75:FEES


I want to split this into a collection of Strings, with a separator, the $-sign.
So that I have for example a list of strings, one string contains a :20:, :25: and a :75: line. The $-sign is just a separator and not included.
The first result would look like:

:20:test1
:25:payment1
:75:FEES




Because the files are big, I process them with a BufferedStreamReader,
I tried to do following:

context.lines()
.map(line -> line.split("$"))
.collect(Collectors.toList())

But this returns a collection of 11 String elements, containing each line of my file as a separate String, while I expected a collection of 3 String elements.


Who can help?