JAVA API ----- InetAddress 、URL

InetAddress

This class represents an Internet Protocol (IP) address.
IP addresses are 32-bit or 128-bit unsigned number used by the IP, UDP and TCP protocols to build low-level protocol. IP address structure defined by RFC 790: Assigned Numbers, RFC 1918 : Address Allocation for Private Internets, RFC 2365: Administratively Scoped IP Multicast and RFC 2373: IP Version 6 Addressing Architecture . One example InetAddress by a corresponding IP address and host name may composition (depending on whether it is configured with the host name or has completed reverse host name resolution).

This class constructor is not, use the static method returns a InetAddress instance the InetAddress.getLocalHost () returns the address of the local host
next class in the method of a paste:

Here Insert Picture Description
Here Insert Picture Description

URL

Class URL represents a Uniform Resource Locator, point to on the World Wide Web "resources" pointer. Resources can be as simple as a file or directory, or it may be a reference to the more complex objects, such as a query to a database or search engine.
In general, URL can be divided into several parts. Consider the following example:

 http://www.example.com/docs/resource1.html

The above URL indicates the protocol to use is http (Hypertext Transfer Protocol), and the information that resides on the host named www.example.com. Information on the host named /docs/resource1.html. The exact meaning of this name on the host depends on the protocol and host. Information typically resides in a file, but it can be generated on the fly. This component is called the path component of the URL.

URL can optionally specify a "port", which is the port number TCP connections on the remote host. If the port is not specified, the default port protocol is used. For example, the default port for http is 80. The other port can be specified as:

 http://www.example.com:1080/docs/resource1.html

URL syntax being defined by RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax, by correcting RFC 2732: Format for Literal IPv6 Addresses in URLs. Literal IPv6 address format also supports scope_ids. Scope_ids describes the syntax and usage here.

URL may be attached a "fragment", also referred to as "ref" or "Reference." Segment is represented by a sharp sign character "#" followed by more characters. E.g,

 http://java.sun.com/index.html#chapter1

This fragment is not technically part of the URL. Instead, it represents After retrieving the specified resource, the application of this section chapter1 tag chapter1 attached document. Meaning tag is resource specific.

An application can also specify a "relative URL", it contains sufficient information with respect to another URL to access the resource. HTML pages often use a relative URL. For example, if the contents of the URL:

 http://java.sun.com/index.html

Contained therein relative URL:
FAQ.html
This will be a shorthand:
http://java.sun.com/FAQ.html
relative URL need not specify all of the components of the URL. If the protocol, host name or port number is missing, the value is inherited from the fully specified URL. You must specify the file component. Optional fragment is not inherited.

The URL class itself does not encode or decode assembly according to any URL escape mechanism defined in RFC2396. Callers are responsible for coding any field need to be escaped before calling the URL, and any escaped fields returned from the URL to be decoded. Further, since the URL does not have knowledge of the URL escape, and therefore does not recognize the equivalence between the same URL in the form of encoding or decoding. For example, two URL:

http://foo.com/hello world / and http://foo.com/hello world will be treated as unequal.
Note that, in some cases, the URI class does perform escaping of its component fields. URL encoding and decoding management recommended to use an URI, using the toURI () and URI.toURL () to convert between the two classes.

And it may also be used URLEncoder URLDecoder class, but only for the encoding scheme defined in RFC2396 different HTML form encoding.

Next to affix the class constructor:
Here Insert Picture Description

And its Summary
Here Insert Picture DescriptionHere Insert Picture Description

Guess you like

Origin blog.csdn.net/m0_38083682/article/details/91414911