java: search & replace in a Stream

io, java, regex, replace, stream

Solution

You can use the class provided here if static replacement rules are enough for you.

Problem

How do I do on-the-fly search & replace in a Java Stream (input or output)? I don't want to load the stream into memory or to a file. I just see the bytes passing by and I need to do some replacements. The sequences being replaced are short (up to 20 bytes).

Original source