Team,
I have come across the code like below,
private static String getResponse (HttpURLConnection connection) throws Exception { String responseString = null; int responseCode = connection.getResponseCode(); String responseMessage = connection.getResponseMessage(); Log.debug("%s - Response code is \"%s\" with message \"%s\"", methodName, responseCode, responseMessage); String line = null; if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader bufferedReader = null; try { InputStream inputStream = connection.getInputStream(); if (inputStream != null) { bufferedReader = Util.bufferedReader( inputStream, Util.Encod.UTF8); StringBuilder response = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { response.append(line); response.append(Util.getNewLine()); } responseString = response.toString(); } } finally { if (bufferedReader != null) { bufferedReader.close(); } } Log.signature.debug( "%s - Received following JSON response : %s", methodName, responseString); } return responseString; } Here they have already received the response like below right?
String responseMessage = connection.getResponseMessage() Then why they are again using connection.getInputStream()
Is there any difference?
If possible could you please also explain some example OR when to use the below than the above getResponseMessage() / getInputStream()
Class URLConnection public Object getContent() throws IOException public Object getContent(Class[] classes) throws IOException