Java Read site source line by line


/ Published in: Java
Save to your folder(s)

Java Read Site Source code Line by Line :D


Copy this code and paste it in your HTML
  1. import java.net.*;
  2. import java.io.*;
  3.  
  4. class ...
  5.  
  6. static URL url;
  7. static URLConnection urlc;
  8. static BufferedReader br;
  9. static String line;
  10.  
  11. ... public static void main(String args[])
  12.  
  13. try {
  14.  
  15. url = new URL("Http://website.tld");
  16. urlc = url.openConnection();
  17. br = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
  18. while((line = br.readLine()) != null)
  19. {
  20. System.out.println(line);
  21. }
  22.  
  23. } catch(Exception e) {
  24. System.out.println("There was an error in your URL!");
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.