0

I would like to replace some text in a NetworkStream. Ideally by using a Regex to find what I want to replace. The consuming part takes a Stream and I would not like to modify it.

I image something like this?

Stream outputStream = new StreamChanger(inputStream, "apple", "banana");

Is there an existing component or pattern which can do this?

frankhommers
  • 1,169
  • 12
  • 26

1 Answers1

0

You will probably need to roll your own...some pseudocode:

var changedString = inputStream.read(); changedString = changedString.replace("apple", "banana");

Stream outputStream = new StreamWriter(path); outputStream.Write(changedString);

AS7K
  • 417
  • 4
  • 20
  • Of course not. I would continue to read from the steam...was just saying as an example, you'd read from it, modify it, and output it to your "output" stream. – AS7K Mar 30 '17 at 20:39
  • If you want I'll write a StreamChanger class for this, but it may need to be next week : -/ – AS7K Mar 31 '17 at 14:21