Nineth Week Java Learning Summary code:
Learning content:
URL class
The URL class is an important class in the java.net package, where an instance of the URL encapsulates a uniform Resource locator, and the application that uses the URL to create the object is called the client program.
A URL object typically contains the most basic three-part information: protocol, address, resource.
Construction Method:
The URL class typically creates a URL object using the following construction method:
**public URL(String spec) throws MalformedURLException**
**public URL(String protocol, String host,String file) throws MalformedURLException**
InetAddress class
- Address means: Domain name, IP address
-
Get host address on Internet: Use the static method of the Interaddress class Getbyname (String s), which returns the domain name and IP address of the object that contains the host address.
- Public String gethostname () gets the domain name contained in the object
- Gethostaddress () Gets the IP address that the object contains.
-
Get native Address: Use the static method of the Interaddress class Getlocalhost (), the returned object contains the domain name and IP address of the local machine.
Broadcast datagram:
- The Class D address is not used to represent your location, that is, you cannot use a class D address on your network to find your computer.
- 224.0.0.0~224.255.255.255 is a reserved address, called a Class D address.
- Hosts that want to broadcast or receive broadcasts must be joined to the same class D address.
Code Cloud Link: HTTPS://GITEE.COM/BESTI-IS-JAVA-2018/20165213ZQH
Java Nineth Week Study summary