How to convert an InputStream to a String in Java

Can someone please explain me how to convert a object to a String?


  • Use IOUtils class as follows.

    StringWriter writer = new StringWriter();
    IOUtils.copy(inputStream, writer, encoding);
    String theString = writer.toString();
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion