Java API Tutorial - Java URLConnection .getInputStream ()








Syntax

URLConnection.getInputStream() has the following syntax.

public InputStream getInputStream()    throws IOException

Example

In the following code shows how to use URLConnection.getInputStream() method.

//ww  w . ja va 2  s  .  c o  m
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class Main{
  public static void main(String args[]) throws Exception {
    URL url = new URL("http://www.google.com");
    URLConnection httpCon = (URLConnection) url.openConnection();

    InputStream s = httpCon.getInputStream();


 }
}