Create BufferedReader from InputStreamReader and URL : InputStreamReader « File Input Output « Java





Create BufferedReader from InputStreamReader and URL

 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class Main {
  public static void main(String[] args) throws Exception {
    URL myURL = new URL("http://www.google.com");
    BufferedReader so = new BufferedReader(new InputStreamReader(myURL.openStream()));
    while (true) {
      String output = so.readLine();
      if (output != null) {
        System.out.println(output);
      } else {
        break;
      }
    }
    so.close();
  }
}

   
  










Related examples in the same category

1.Create BufferedReader from InputStreamReader
2.Create BufferedReader from InputStreamReader and read line by line
3.Reading ISO Latin-1 Encoded Data
4.Deal with Keyboard Input with BufferedReader