Guest User

Untitled

a guest
Mar 24th, 2015
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public String GET()
  2.     {
  3.         String link = "http://site.com/sample.json";
  4.         HttpURLConnection urlConnection = null;
  5.         InputStream inStream = null;
  6.         URL url = new URL(link);
  7.         urlConnection = (HttpURLConnection) url.openConnection();
  8.         urlConnection.setRequestMethod("GET");
  9.         urlConnection.setDoOutput(true);
  10.         urlConnection.setDoInput(true);
  11.         urlConnection.connect();
  12.         inStream = urlConnection.getInputStream();
  13.         BufferedReader bReader = new BufferedReader(new InputStreamReader(inStream));
  14.         String temp, response = "";
  15.         while ((temp = bReader.readLine()) != null) {
  16.             response += temp;
  17.         }
  18.         return response;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment