Advertisement
ToppseDev

Read URL

May 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. public static void main(String[] args) throws IOException {
  2.     URL url = new URL(URL);
  3.     URLConnection uc = url.openConnection();
  4.         uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
  5.         uc.connect();
  6.     InputStreamReader isr = new InputStreamReader(uc.getInputStream());
  7.     BufferedReader br = new BufferedReader(isr);
  8.     String line = "";
  9.     String code = "";
  10.     while((line = br.readLine()) != null) {
  11.         code += line + "\r\n";
  12.     }
  13.     br.close();
  14.     isr.close();
  15.     System.out.println(code);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement