Wednesday, 10 February 2016

Displaying source code of a web page

//URLConnectionExample.java

import java.io.*;
import java.net.*;
public class URLConnectionExample
{
public static void main(String[] args)
{
try
{
URL url=new URL("http://javaforocpjp.blogspot.in/index.html");
URLConnection urlcon=url.openConnection();
InputStream stream=urlcon.getInputStream();
int i;
while((i=stream.read())!=-1)
{
System.out.print((char)i);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}  

No comments:

Post a Comment