Czy mogę jakoś zoptymalizować to? Poczytałem trochę dokumentacji, ale nie znalazłem nic ciekawego. Może ktoś podpowie.
URL url = new URL(myURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
String inline = new String();
String finalStr;
ArrayList<Repo> repos = new ArrayList<>();
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
//reading json from api
Scanner scanner = new Scanner(url.openStream());
while(scanner.hasNext()) {
inline+=scanner.nextLine();
}
scanner.close();
JSONArray jsonarray = new JSONArray(inline);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
}
}
ShalomShalomShalomShalom