I have been trying to find an example of how to use java-streams as compressor. I still have not figured out how to do this and I have neither found anyone else that done it. So that I would like to do is to count occurrences, of something, in the stream as long as they are in unbroken row. A simple example would be something like this:
String str = "...---...";
String compressed = func(str);
compressed.equals("3.3-3.");
It is simple to get string into a stream of integers and count the occurrences of them. But count the occurrences in a unbroken sequence I can not figure out how to do. Is there a good way of using .reduce to make this happen?