Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // servlet is local to the app
- String requestURL = request.getRequestURL().toString();
- String servletPath = request.getServletPath();
- String serverPath = requestURL.substring(0,requestURL.indexOf(servletPath));
- URL url = new URL(serverPath + "/getScores");
- URLConnection conn = url.openConnection();
- conn.setConnectTimeout(12000);
- InputStream is = conn.getInputStream();
- StringWriter writer = new StringWriter();
- IOUtils.copy(is, writer, "UTF-8");
- String jsonStr = writer.toString();
- Gson gson = new Gson();
- Type listType = new TypeToken<List<ScoreRecord>>() {}.getType();
- List<ScoreRecord> scores = gson.fromJson(jsonStr, listType);
Add Comment
Please, Sign In to add comment