Here you can find the source of readURLJSONArray(String urlString)
public static JSONArray readURLJSONArray(String urlString)
//package com.java2s; //License from project: Open Source License import org.json.JSONArray; import org.json.JSONException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; public class Main { public static JSONArray readURLJSONArray(String urlString) { try {// w ww . ja v a 2 s . c o m return new JSONArray(readURL(urlString)); } catch (JSONException e) { return null; } } public static String readURL(String urlString) { try { URL url = new URL(urlString); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); StringBuilder sb = new StringBuilder(); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) sb.append(chars, 0, read); reader.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return ""; } }