Add api football files updater
This commit is contained in:
@@ -91,80 +91,4 @@ public class APIFootballConnector {
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
private JSONArray getDataAsJSONArray(String requestUrl) {
|
||||
|
||||
String rawData = getRawData(requestUrl);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONArray data = null;
|
||||
try {
|
||||
data = (JSONArray) parser.parse(rawData);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private JSONObject getDataAsJSONObject(String requestUrl) {
|
||||
|
||||
String rawData = getRawData(requestUrl);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject data = null;
|
||||
try {
|
||||
data = (JSONObject) parser.parse(rawData);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
String getRawData(String requestUrl) {
|
||||
|
||||
HttpClient client = HttpClientBuilder.create().build();
|
||||
HttpGet request = new HttpGet(requestUrl);
|
||||
|
||||
// add request header
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
} catch (ClientProtocolException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
rd = new BufferedReader(
|
||||
new InputStreamReader(response.getEntity().getContent())
|
||||
);
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line = "";
|
||||
while (true) {
|
||||
try {
|
||||
line = rd.readLine();
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Stop reading if last line was found.
|
||||
if (line == null) break;
|
||||
|
||||
result.append(line);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user