Advertisement
Guest User

webpage result java

a guest
Apr 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.net.*;
  2. import java.io.*;
  3.  
  4. public class URLReader {
  5. public static void main(String[] args) throws Exception {
  6.  
  7. try {
  8.  
  9. URL url = new URL("https://sites.google.com/site/edugamesunlimited/games/achievement-unlocked-2");
  10. // read text returned by server
  11. URLConnection urlConnection = url.openConnection();
  12. InputStream is = urlConnection.getInputStream();
  13. InputStreamReader isr = new InputStreamReader(is);
  14. String line;
  15. int numCharsRead;
  16. char[] charArray = new char[1024];
  17. StringBuffer sb = new StringBuffer();
  18. while ((numCharsRead = isr.read(charArray)) > 0) {
  19. sb.append(charArray, 0, numCharsRead);
  20. }
  21. String result = sb.toString();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement