Advertisement
Tyluur

Untitled

May 21st, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. package com.sevador.utility.loaders;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.net.MalformedURLException;
  7. import java.net.URL;
  8. import java.net.URLConnection;
  9. import java.util.ArrayList;
  10.  
  11. /**
  12. * @author DragonKK
  13. */
  14.  
  15. public class WebPage {
  16.  
  17. private URL url;
  18. private ArrayList<String> lines;
  19.  
  20. public WebPage(String url) throws MalformedURLException {
  21. if (!url.startsWith("http://"))
  22. url = "http://" + url;
  23. this.url = new URL(url);
  24. }
  25.  
  26. public void load() throws IOException {
  27. lines = new ArrayList<String>();
  28. URLConnection c = url.openConnection();
  29. c.setReadTimeout(3000);
  30. BufferedReader stream = new BufferedReader(new InputStreamReader(
  31. c.getInputStream()));
  32. String line;
  33. while ((line = stream.readLine()) != null) {
  34. lines.add(line);
  35. }
  36. stream.close();
  37.  
  38. }
  39.  
  40. public void setLines(ArrayList<String> lines) {
  41. this.lines = lines;
  42. }
  43.  
  44. public ArrayList<String> getLines() {
  45. return lines;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement