Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static URL getUrlForPage(String pageAdress){
- try {
- return new URL(pageAdress);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static String downloadPageToString(URL url){
- String res = "";
- InputStream is;
- BufferedReader br;
- try {
- is = url.openStream();
- if(is != null){
- br = new BufferedReader(new InputStreamReader(is));
- String line;
- while ((line = br.readLine()) != null) {
- res += line;
- }
- return res;
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return "";
- }
- private static ArrayList<Integer> loadDoctorInInstitutionJSON(String json){
- ArrayList<Integer> res = new ArrayList<>();
- JSONArray ja = null;
- try {
- ja = new JSONArray(json);
- for(int i=0;i<ja.length();i++){
- JSONObject jo = ja.getJSONObject(i);
- res.add(jo.getInt("DoctorID"));
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- return res;
- }
- loadDoctorInInstitutionJSON(downloadPageToString(getUrlForPage("adresa_stranky.php")));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement