If you are using http to communicate, better to use HttpURLConnection.
JsonArray jsonArray;
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("http://www.example.com/endpoint").openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
httpURLConnection.connect();
InputStream is = httpsURLConnection.getInputStream();
try {
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        StringBuilder sb = new StringBuilder();
        while (br.readLine() != null) {
            sb.append(br.readLine()).append("\n");
        }
        br.close();
        jsonArray = new JSONArray(sb.toString());
    } catch (IOException | JSONException e) {
        jsonArray = null;
    }