Advertisement
Guest User

webget

a guest
Sep 26th, 2012
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.io.InputStreamReader;
  4. import java.io.BufferedReader;
  5.  
  6. public class WebGet {
  7.    
  8.     public static String httpget(String location)   {
  9.         String webpage = "";
  10.         try {
  11.             URL url = new URL(location);
  12.             URLConnection urlConnection = url.openConnection();
  13.             InputStreamReader isr = new InputStreamReader(urlConnection.getInputStream());
  14.             BufferedReader buff = new BufferedReader(isr);
  15.             String line;
  16.             while((line = buff.readLine()) != null) {
  17.                 webpage = webpage + line + "\n";
  18.             }
  19.         }
  20.         catch(Exception e)  {
  21.             webpage = "";
  22.         }
  23.         return webpage;
  24.     }
  25.     private WebGet() {}
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement