Advertisement
Guest User

Untitled

a guest
Nov 19th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public static String getJSONResponseFromURL(String url, Hashtable<String, String> httpGetParams){
  2. String json_string="";
  3. List<NameValuePair> nvps=buildNameValuePair(httpGetParams);
  4. url=buildGetUrl(nvps,url);
  5. System.out.println("URL==>"+url);
  6. InputStream is = null;
  7. try{
  8. HttpGet httpget = new HttpGet(url);
  9. HttpResponse response = getThreadSafeClient().execute(httpget);
  10.  
  11. HttpEntity entity = response.getEntity();
  12. is = entity.getContent();
  13. BufferedReader reader=new BufferedReader(new InputStreamReader(is),8192);
  14. String line=null;
  15. while((line=reader.readLine())!=null) {json_string=json_string+line;}
  16. response.getEntity().consumeContent();
  17. System.out.println("Json Response==>"+json_string);
  18. }catch(Exception e){
  19. return null;
  20. }
  21. return json_string;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement