Wednesday, 6 March 2013

Program to fetch the source code of a given website


import java.net.*;
import java.util.*;
import java.io.*;
class FetchCode
{
public static void main(String args[])throws Exception
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the url: ");
String site=s.next();
URL u=new URL(site);
BufferedReader br=new BufferedReader(new InputStreamReader(u.openStream()));
String line;
while((line=br.readLine())!=null)
System.out.println(line);

br.close();

}
}


NOTE:- While writting the input URL write its full name for example for FACEBOOK write    http://www.facebook.com

No comments:

Post a Comment