Main method and constructor of URL classes

zhaozj2021-02-16  48

The URL is a string that describes how to locate resources on the Internet. A complete programmer can easily use the URL

Internet communication on the Internet

A complete URL consists of a protocol, host name, port number, file name, and reference. example

http://tech.china.com:80/1_cn/news/index.html

It uses the HTTP protocol and uses port 80 to connect to the host Teach.China.com to access file /zh_cn/news/index.html

The URL class in Java represents various URLs, the following is a constructor

URL (String Spec)

URL (String Protocol, String Host, Int Port, String File)

URL (String Protocol, String Host, Int Port, String File, URLStreamHandler Handler)

String Protocol, String Host, String File

URL (URL CONTEXT, STRING SPEC)

URL (URL Context, String Spec, UrlstreamHandler Handler)

Parameter Description

Context explanates SPEC when spec for relative URL

Handler Specifies the processor of the context

Host host name

File file path name

Port number to use

Protocol's protocol to use

SPEC URL string

Use the URL class to get the URL component (protocol, host number, port number, file name, reference), in addition, it also provides acquiring URL

Representative resources

Main method of URL

Object getContent () // Get the content indicated by this URL

String getfile () // Get the file name of the URL

String gethost () // Get the host number of the URL

INT getport () // Get the port number of the URL

String getProtocol () // Get the protocol of this URL

String getQuery () // Get the Query section of this URL

String getUserInfo () / / User information for this URL

UrlConnection OpenConnection () // Open the connection indicated by the URL

InputStream OpenStream () // Open the input stream of this URL

Booleam Samefile (URL OTHER) / / Decades whether the two URL points to the same file

Void Set (String Protocol, String Host, Int Port, String File, String REF) // Setting this URL domain

String TOEXTERNALMM () // Returns the string of the URL

转载请注明原文地址:https://www.9cbs.com/read-20074.html

New Post(0)