Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Inet4Address

public final class Inet4Address
extends InetAddress

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


An IPv4 address. See InetAddress.

Summary

Public methods

boolean isAnyLocalAddress()

Returns whether this is the IPv6 unspecified wildcard address :: or the IPv4 "any" address, 0.0.0.0.

boolean isLinkLocalAddress()

Returns whether this address is a link-local address or not.

boolean isLoopbackAddress()

Returns whether this address is a loopback address or not.

boolean isMCGlobal()

Returns whether this address is a global multicast address or not.

boolean isMCLinkLocal()

Returns whether this address is a link-local multicast address or not.

boolean isMCNodeLocal()

Returns whether this address is a node-local multicast address or not.

boolean isMCOrgLocal()

Returns whether this address is a organization-local multicast address or not.

boolean isMCSiteLocal()

Returns whether this address is a site-local multicast address or not.

boolean isMulticastAddress()

Returns whether this address is a multicast address or not.

boolean isSiteLocalAddress()

Returns whether this address is a site-local address or not.

Inherited methods

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

Public methods

isAnyLocalAddress

Added in API level 1
boolean isAnyLocalAddress ()

Returns whether this is the IPv6 unspecified wildcard address :: or the IPv4 "any" address, 0.0.0.0.

Returns
boolean

isLinkLocalAddress

Added in API level 1
boolean isLinkLocalAddress ()

Returns whether this address is a link-local address or not.

Valid IPv6 link-local addresses have the prefix fe80::/10.

RFC 3484 "Default Address Selection for Internet Protocol Version 6 (IPv6)" states that both IPv4 auto-configuration addresses (prefix 169.254/16) and IPv4 loopback addresses (prefix 127/8) have link-local scope, but Inet4Address only considers the auto-configuration addresses to have link-local scope. That is: the IPv4 loopback address returns false.

Returns
boolean

isLoopbackAddress

Added in API level 1
boolean isLoopbackAddress ()

Returns whether this address is a loopback address or not.

Valid IPv4 loopback addresses have the prefix 127/8.

The only valid IPv6 loopback address is ::1.

Returns
boolean

isMCGlobal

Added in API level 1
boolean isMCGlobal ()

Returns whether this address is a global multicast address or not.

Valid IPv6 global multicast addresses have the prefix ffxe::/16, where x is a set of flags and the additional 112 bits make up the global multicast address space.

Valid IPv4 global multicast addresses are the range of addresses from 224.0.1.0 to 238.255.255.255.

Returns
boolean

isMCLinkLocal

Added in API level 1
boolean isMCLinkLocal ()

Returns whether this address is a link-local multicast address or not.

Valid IPv6 link-local multicast addresses have the prefix ffx2::/16, where x is a set of flags and the additional 112 bits make up the link-local multicast address space.

Valid IPv4 link-local multicast addresses have the prefix 224.0.0/24.

Returns
boolean

isMCNodeLocal

Added in API level 1
boolean isMCNodeLocal ()

Returns whether this address is a node-local multicast address or not.

Valid IPv6 node-local multicast addresses have the prefix ffx1::/16, where x is a set of flags and the additional 112 bits make up the link-local multicast address space.

There are no valid IPv4 node-local multicast addresses.

Returns
boolean

isMCOrgLocal

Added in API level 1
boolean isMCOrgLocal ()

Returns whether this address is a organization-local multicast address or not.

Valid IPv6 organization-local multicast addresses have the prefix ffx8::/16, where x is a set of flags and the additional 112 bits make up the link-local multicast address space.

Valid IPv4 organization-local multicast addresses have the prefix 239.192/14.

Returns
boolean

isMCSiteLocal

Added in API level 1
boolean isMCSiteLocal ()

Returns whether this address is a site-local multicast address or not.

Valid IPv6 site-local multicast addresses have the prefix ffx5::/16, where x is a set of flags and the additional 112 bits make up the link-local multicast address space.

Valid IPv4 site-local multicast addresses have the prefix 239.255/16.

Returns
boolean

isMulticastAddress

Added in API level 1
boolean isMulticastAddress ()

Returns whether this address is a multicast address or not.

Valid IPv6 multicast addresses have the prefix ff::/8.

Valid IPv4 multicast addresses have the prefix 224/4.

Returns
boolean

isSiteLocalAddress

Added in API level 1
boolean isSiteLocalAddress ()

Returns whether this address is a site-local address or not.

For the purposes of this method, valid IPv6 site-local addresses have the deprecated prefix fec0::/10 from RFC 1884, not the modern prefix fc00::/7 from RFC 4193.

RFC 3484 "Default Address Selection for Internet Protocol Version 6 (IPv6)" states that IPv4 private addresses have the prefix 10/8, 172.16/12, or 192.168/16.

Returns
boolean true if this instance represents a site-local address, false otherwise.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.