游.程
2008-11-21 16:47
采纳率: 33.3%
浏览 2.0k
已采纳

如何在 Java 中将 InputStream 转换为字符串?

If you have a java.io.InputStream object, how should you process that object and produce a String?


Suppose I have an InputStream that contains text data, and I want to convert it to a String, so for example I can write that to a log file.

What is the easiest way to take the InputStream and convert it to a String?

public String convertStreamToString(InputStream is) { 
    // ???
}

转载于:https://stackoverflow.com/questions/309424/how-to-read-convert-an-inputstream-into-a-string-in-java

30条回答 默认 最新

相关推荐 更多相似问题