How to convert an InputStream to a String in Java - Programmers Heaven

Howdy, Stranger!

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

Categories

How to convert an InputStream to a String in Java

Damian99Damian99 USAPosts: 116Member

Can someone please explain me how to convert a java.io.InputStream object to a String?

Tagged:

Comments

  • DavidMDavidM USAPosts: 342Member

    Use IOUtils class as follows.

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