Java provided by the URL class package, we can like IE browser from the designated URL to download the Web page, and, the download is absolutely true HTML, using this principle we can make their own kernel of the browser it!
See this is the source of the implementation principle:
Import Java.net.URL;
Import java.net.URLConnection;
Import java.io.IOException;
Import Java.util.Date;
public class Urlc {void display () {byte buf[]=new byte[100];
try {System.out.print ("Please enter the URL address of the file:");
Reads the URL int ount=system.in.read (BUF) entered by the user;
String Addr=new string (Buf,0,count);
Passes the URL string entered by the user to the URL class object URL url=new url (addr);
Creates a URLConnection object that returns the connection to the URLConnection object with the OpenConnection method of the URL the OpenConnection return value of the URL is a urlconnection
URLConnection C = url.openconnection ();
The connection C.connect () is established by the URLConnection Connect () method;
Displays information about the connection, which is the URLConnection method System.out.println ("Content type:" +c.getcontenttype ());
SYSTEM.OUT.PRINTLN ("Content code:" +c.getcontentencoding ());
System.out.println ("Content Length:" +c.getcontentlength ());
System.out.println ("Date Created:" +new date (C.getdate ()));
System.out.println ("Last Modified:" +new date (c.getlastmodified ()));
System.out.println ("End Date:" +new date (C.getexpiration ()));
catch (IOException e) {System.out.println (e);} public static void Main (string[] args) {URLC aPp=new URLC ();
App.display (); }
}