I have several output listeners that are implementing OutputStream. It can be either a PrintStream writing to stdout or to a File, or it can be writing to memory or any othe
You may use Apache Commons IO:
try (OutputStream outputStream = ...) { IOUtils.write("data", outputStream, "UTF-8"); }