Java by Petr Sladek
If you need to convert OutputStream to String, you can use the ByteArrayOutputStream class:
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
writeSomethingToStream(outputStream);
String resultString = outputStream.toString();
For example you have a method that writes something to OutputStream and you need its result as a String in Java:
writeSomethingToStream(OutputStream out)