Issue
I have used this code. Now, I want to get the header into the response. How can I do this?
HttpURLConnection conn = (HttpURLConnection) url_.openConnection();
conn.setRequestMethod("GET");
InputStream in = new BufferedInputStream(conn.getInputStream());
String jsonStr = convertStreamToString( in );
public static String convertStreamToString(InputStream input) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
input.close();
return sb.toString();
}
Screenshot:
Solution
I get answer :
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpPost = new HttpGet("https://api***********.php");
HttpResponse httpResponse = httpclient.execute(httpPost);
Header[] headers = httpResponse.getAllHeaders();
String Token="";
for (Header header : headers) {
System.out.println("Key : " + header.getName()+ " ,Value : " + header.getValue());
if (header.getName().equals("your_parm_key")) {
Token = header.getValue();
}
}
Answered By - krish singh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.