thelittlewozniak

Untitled

Jan 12th, 2019
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. List<Conversation> conversations=null;
  2.         try{
  3.             URL url=new URL("http://androidweb.azurewebsites.net/api/Conversation/GetAll");
  4.             HttpURLConnection urlConnection=(HttpURLConnection) url.openConnection();
  5.             urlConnection.setRequestMethod("GET");
  6.             urlConnection.setRequestProperty("Content-Type","text/plain");
  7.             InputStream is=urlConnection.getInputStream();
  8.             BufferedReader br =new BufferedReader(new InputStreamReader(is,"iso-8859-1"));
  9.             String result="";
  10.             String line="";
  11.             while((line=br.readLine())!=null){
  12.                 result+=line;
  13.             }
  14.             br.close();
  15.             is.close();
  16.             urlConnection.disconnect();
  17.             conversations=new ObjectMapper().readValue(result, new TypeReference<List<Conversation>>() {});
  18.         }
  19.         catch (Exception e){
  20.             e.printStackTrace();
  21.         }
  22.         return conversations;
Advertisement
Add Comment
Please, Sign In to add comment