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
By design it is to be done this way:
OutputStream out = ...; try (Writer w = new OutputStreamWriter(out, "UTF-8")) { w.write("Hello, World!"); } // or w.close(); //close will auto-flush