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!
Please see this is the implementation of the principle of the source program:
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:");
//Read the user input URL
int Ount=system.in.read (BUF);
string Addr=new string
(Buf,0,count);
//The URL string entered by the user is passed into the URL class object
url url=new url (addr);
//creates the URLConnection object and returns the connection to the URLConnection object using the OpenConnection method of the URL
//The OpenConnection return value of the URL is actually a urlconnection
urlconnection C = url.openconnection ();
Establish a connection
with URLConnection Connect () method
C.connect ();
//Displays information about the connection, these are URLConnection methods
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.