Most visited

Recently visited

Added in API level 1

Inet4Address

public final class Inet4Address
extends InetAddress

java.lang.Object
   ↳ java.net.InetAddress
     ↳ java.net.Inet4Address


此类表示Internet协议版本4(IPv4)地址。 通过定义RFC 790: Assigned NumbersRFC 1918: Address Allocation for Private Internets ,并RFC 2365: Administratively Scoped IP Multicast

Textual representation of IP addresses

Textual representation of IPv4 address used as input to methods takes one of the following forms:
d.d.d.d
d.d.d
d.d
d

当指定四个部分时,每个部分都被解释为一个数据字节,并从左到右分配给IPv4地址的四个字节。

当指定三部分地址时,最后一部分被解释为16位数量并放置在网络地址的最右边两个字节中。 这使三部分地址格式便于将B类网络地址指定为128.net.host。

当提供两部分地址时,最后一部分被解释为24位数量并放置在网络地址的最右边三个字节中。 这使得两部分地址格式便于将A类网络地址指定为net.host。

当只给出一个部分时,该值直接存储在网络地址中,而不进行任何字节重新排列。

对于将文本表示形式作为输出值返回的方法,将使用第一种形式,即四角形的字符串。

The Scope of a Multicast Address

Historically the IPv4 TTL field in the IP header has doubled as a multicast scope field: a TTL of 0 means node-local, 1 means link-local, up through 32 means site-local, up through 64 means region-local, up through 128 means continent-local, and up through 255 are global. However, the administrative scoping is preferred. Please refer to RFC 2365: Administratively Scoped IP Multicast

Summary

Public methods

boolean equals(Object obj)

将此对象与指定的对象进行比较。

byte[] getAddress()

返回此 InetAddress对象的原始IP地址。

String getHostAddress()

以文本呈现形式返回IP地址字符串。

int hashCode()

返回此IP地址的哈希码。

boolean isAnyLocalAddress()

用于检查通配符地址中的InetAddress的实用程序。

boolean isLinkLocalAddress()

用于检查InetAddress是否为链接本地地址的实用程序。

boolean isLoopbackAddress()

检查InetAddress是否为环回地址的实用程序。

boolean isMCGlobal()

检查多播地址是否具有全局范围的实用程序。

boolean isMCLinkLocal()

检查多播地址是否具有链接范围的实用程序。

boolean isMCNodeLocal()

检查组播地址是否具有节点范围的实用程序。

boolean isMCOrgLocal()

检查组播地址是否具有组织范围的实用程序。

boolean isMCSiteLocal()

检查组播地址是否具有站点范围的实用程序。

boolean isMulticastAddress()

检查InetAddress是否为IP多播地址的实用程序。

boolean isSiteLocalAddress()

检查InetAddress是否为站点本地地址的实用程序。

Inherited methods

From class java.net.InetAddress
From class java.lang.Object

Public methods

equals

Added in API level 1
boolean equals (Object obj)

将此对象与指定的对象进行比较。 当且仅当参数不是null并且它表示与此对象相同的IP地址时,结果为true

如果 getAddress返回的字节数组的长度对于两者都是相同的,并且每个数组组件对于字节数组都是相同的,则 InetAddress两个实例表示相同的IP地址。

Parameters
obj Object: the object to compare against.
Returns
boolean true if the objects are the same; false otherwise.

也可以看看:

getAddress

Added in API level 1
byte[] getAddress ()

返回此InetAddress对象的原始IP地址。 结果是网络字节顺序:地址的最高位字节在getAddress()[0]

Returns
byte[] the raw IP address of this object.

getHostAddress

Added in API level 1
String getHostAddress ()

以文本呈现形式返回IP地址字符串。

Returns
String the raw IP address in a string format.

hashCode

Added in API level 1
int hashCode ()

返回此IP地址的哈希码。

Returns
int a hash code value for this IP address.

isAnyLocalAddress

Added in API level 1
boolean isAnyLocalAddress ()

用于检查通配符地址中的InetAddress的实用程序。

Returns
boolean a boolean indicating if the Inetaddress is a wildcard address.

isLinkLocalAddress

Added in API level 1
boolean isLinkLocalAddress ()

用于检查InetAddress是否为链接本地地址的实用程序。

Returns
boolean a boolean indicating if the InetAddress is a link local address; or false if address is not a link local unicast address.

isLoopbackAddress

Added in API level 1
boolean isLoopbackAddress ()

检查InetAddress是否为环回地址的实用程序。

Returns
boolean a boolean indicating if the InetAddress is a loopback address; or false otherwise.

isMCGlobal

Added in API level 1
boolean isMCGlobal ()

检查多播地址是否具有全局范围的实用程序。

Returns
boolean a boolean indicating if the address has is a multicast address of global scope, false if it is not of global scope or it is not a multicast address

isMCLinkLocal

Added in API level 1
boolean isMCLinkLocal ()

检查多播地址是否具有链接范围的实用程序。

Returns
boolean a boolean indicating if the address has is a multicast address of link-local scope, false if it is not of link-local scope or it is not a multicast address

isMCNodeLocal

Added in API level 1
boolean isMCNodeLocal ()

检查组播地址是否具有节点范围的实用程序。

Returns
boolean a boolean indicating if the address has is a multicast address of node-local scope, false if it is not of node-local scope or it is not a multicast address

isMCOrgLocal

Added in API level 1
boolean isMCOrgLocal ()

检查组播地址是否具有组织范围的实用程序。

Returns
boolean a boolean indicating if the address has is a multicast address of organization-local scope, false if it is not of organization-local scope or it is not a multicast address

isMCSiteLocal

Added in API level 1
boolean isMCSiteLocal ()

检查组播地址是否具有站点范围的实用程序。

Returns
boolean a boolean indicating if the address has is a multicast address of site-local scope, false if it is not of site-local scope or it is not a multicast address

isMulticastAddress

Added in API level 1
boolean isMulticastAddress ()

检查InetAddress是否为IP多播地址的实用程序。 IP多播地址是D类地址,即地址的前四位是1110。

Returns
boolean a boolean indicating if the InetAddress is an IP multicast address

isSiteLocalAddress

Added in API level 1
boolean isSiteLocalAddress ()

检查InetAddress是否为站点本地地址的实用程序。

Returns
boolean a boolean indicating if the InetAddress is a site local address; or false if address is not a site local unicast address.

Hooray!