How do I convert an InputStream to a String in Java?

后端 未结 7 2061
梦毁少年i
梦毁少年i 2020-12-08 15:41

Suppose I have an InputStream that contains text data, and I want to convert this to a String (for example, so I can write the contents of the stre

7条回答
  •  没有蜡笔的小新
    2020-12-08 16:01

    If you want to do it simply and reliably, I suggest using the Apache Jakarta Commons IO library IOUtils.toString(java.io.InputStream, java.lang.String) method.

提交回复
热议问题