I want to convert the java.io.InputStream object to String.
If InputStream contains textual data, I think we can change it to String What do I do?
p.s. Please let me know the simplest way to do it in the code below.
public String convertStreamToString(InputStream is) { // ??? }
string java io stream inputstream
It's easy if you use IOUtils.
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, encoding);
String theString = writer.toString();
If I do this or lower it,
String theString = IOUtils.toString(inputStream, encoding);
© 2024 OneMinuteCode. All rights reserved.