I used this question
How to convert InputStream to String in Java?
to convert InputStream to String using this code:
public static String convertStreamToString(java.io.InputStream is) { java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; }
My input stream comes from an HttpURLConnection InputStream, and when I do my conversion to String, the input stream changes and I can no longer use it. This is the error I get:
Premature end of file.' SOAP
What can I do to save my input stream when I convert it to a string with relevant information?
In particular, this is information that changes:
inCache = true (before false) keepAliveConnections = 4 (before 5) keepingAlive = false (before true) poster = null (before it was PosterOutputStream object with values)
Thanks.
Eduardo
source share