I have http response object "httpResponse" which is instance of class javax.ws.rs.core.Response. I have to convert it into a human readable string object for debugging. How can I achieve this?
final InputStream inputStream = (InputStream) httpResponse.getEntity();
final ByteArrayDataSource dataSource = new ByteArrayDataSource(inputStream, ContentType.MULTIPART_FORM_DATA.getMimeType());
final MimeMultipart multipartResponse = new MimeMultipart(dataSource);
I tried doing the below using the inputStream object. The output is all binary. Do I need to do base64 decoding? Thanks.
IOUtils.toString(inputStream, StandardCharsets.UTF_8))
As you said you need decoding.
Source:
https://mkyong.com/java/how-do-convert-byte-array-to-string-in-java/
Here it is explained not only the conversion from bytes to text, but also the conversion from bytes to image or any kind of binary type.