Reading Response From REST URL

private static String getRestCallResponse(String restURL) throws IOException {

String output = "";
StringBuffer response = new StringBuffer("");

URL url = new URL(restURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");

BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

while ((output = br.readLine()) != null) {
response = response.append(output);
}

conn.disconnect();

return response.toString();
}

Comments

Popular posts from this blog

CSM Quiz -2

Enabling WL-Proxy-SSL HTTP header in WebLogic

CSM Quiz -1