feat: refactor city fecth
This commit is contained in:
parent
ebf840a73d
commit
d263a3b68f
@ -7,6 +7,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import eirb.pg203.utils.JSONFetcher;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -28,17 +29,7 @@ public class City {
|
||||
)
|
||||
).toURL();
|
||||
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream()))) {
|
||||
for (String line; (line = reader.readLine()) != null; ) {
|
||||
result.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
return new JSONObject(result.toString());
|
||||
return JSONFetcher.fetch(url);
|
||||
}
|
||||
|
||||
private static Coords getCoordsFromName(String cityName) throws IOException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user