I am using URL class to read an InputStream from it. Is there any way I can use RestTemplate for this?
InputStream input = new URL(url).openStream();
JsonReader reader = new JsonReader(new InputStreamReader(input, StandardCharsets.UTF_8.displayName()));
RestTemplate is meant to encapsulate processing the response (and request) content.
Theoretically, you could write a
HttpMessageConverter that will retrieve and return the
InputStream (or same wrapped version of it), but advise against that.