Back to Archive
Computer Science
QID: #29674
Subject: Computer Science
Status:
Order This Question Now
Need full details for below function for same.
public static int getTransactions(int userId, int locationId, int netStart, int
netEnd) {
int total = 0;
Double totalAmount = 0.0;
try {
String url = "?
userId="+userId;
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Accept", "application/json");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(new
InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
String result=response.toString();
JSONParser parser=new JSONParser();
JSONObject objeto = (JSONObject)parser.parse(result);
JSONArray data = (JSONArray) objeto.get("data");
String page = objeto.get("data").toString();
int totalPag = Integer.parseInt(objeto.get("total_pages").toString());
for(int j=1; j<=totalPag; j++){
url = "?
userId="+userId+"&page="+j;
obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
ZERO AI
Human Written
Human Written
PHD EXPERTS
Verified
Verified
TURNITIN
Clean Report
Clean Report
24/7 SUPPORT
Instant Help
Instant Help