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();
}
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
Post a Comment