When adding to some content to HttpServletResponse in java I can either get the response writer and append:
httpResponse.getWriter().append("Some Content");
Or I can add content to the output-stream:
ServletOutputStream servletOut = httpResponse.getOutputStream();
servletOut.write(someByteArray);
Is the only difference between the two is that the first gets strings/char-sequences and the second gets bytes (of course the content-type is affected as well)? Should I prefer one over the other? When should I use which?
Below table shows difference between them, You can use any of these based on requirement which fits in the table.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With