piotrek5402

Wchodzenie na stronę.

Dec 22nd, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public static String getHTML(String addr)
  2.     {
  3.         URL url;
  4.           HttpURLConnection conn;
  5.           BufferedReader rd;
  6.           String line;
  7.           String result = "";
  8.           try {
  9.              url = new URL(addr);
  10.              conn = (HttpURLConnection) url.openConnection();
  11.              conn.setRequestMethod("GET");
  12.              rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  13.              while ((line = rd.readLine()) != null) {
  14.                 result += line;
  15.              }
  16.              rd.close();
  17.           } catch (Exception e) {
  18.              e.printStackTrace();
  19.           }
  20.           return result;
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment