Guest User

Untitled

a guest
Dec 15th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. public static String readJSON(String url) throws IOException {
  2.     URL urlObj = new URL(url);
  3.     HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
  4.     connection.addRequestProperty("Accept", "application/json");
  5.     connection.connect();
  6.     BufferedReader in =new BufferedReader(new InputStreamReader(connection.getInputStream()));
  7.  
  8.     String json = "", tmp;
  9.     while ((tmp = in.readLine()) != null)
  10.           json += tmp;
  11.     connection.disconnect();
  12.  
  13.     return json;
  14. }
Add Comment
Please, Sign In to add comment