Advertisement
Guest User

Untitled

a guest
May 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. GetData(Products products) throws IOException {
  2.         {
  3.             //GET POST SETUP
  4.             URL url = new URL("https://fredagscafeen.dk/api/items/?format=json");
  5.             HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  6.             conn.setRequestMethod("GET");
  7.  
  8.             //STREAM READER SETUP
  9.             BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  10.  
  11.             //SETUP STRING BUILDER
  12.             String line;
  13.             StringBuilder result = new StringBuilder();
  14.  
  15.             //RUNS THROUGH ALL THE DATA
  16.             while ((line = rd.readLine()) != null) {
  17.                 result.append(line);
  18.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement