Reputation: 423
I am trying to convert StreamingOutput to string in Java to pass it to another method. It produces the string but it raises the following error later on.
JAXRSUtils logMessageHandlerProblem Severe: Problem with writing the data, ContentType: text/plain
What's happening?
StreamingOutput stream = method1();
ByteArrayOutputStream output = new ByteArrayOutputStream();
stream.write(output);
String string = new String(output.toString("UTF-8"));
...
public StreamingOutput method1(...){..}
`
Upvotes: 3
Views: 10132
Reputation: 648
I believe you did not properly convert OutputStream to String properly. Please try the code below:
StreamingOutput stream = method1();
ByteArrayOutputStream output = new ByteArrayOutputStream();
stream.write(output);
String string = new String(output.toByteArray(), "UTF-8");
...
public StreamingOutput method1(...){..}
Upvotes: 9