Stay organized with collections
Save and categorize content based on your preferences.
InterfaceAddress
open class InterfaceAddress
This class represents a Network Interface address. In short it's an IP address, a subnet mask and a broadcast address when the address is an IPv4 one. An IP address and a network prefix length in the case of IPv6 address.
Summary
Public methods |
open Boolean |
Compares this object against the specified object.
|
open InetAddress! |
Returns an InetAddress for this address.
|
open InetAddress! |
Returns an InetAddress for the broadcast address for this InterfaceAddress.
|
open Short |
Returns the network prefix length for this address.
|
open Int |
Returns a hashcode for this Interface address.
|
open String |
Converts this Interface address to a String .
|
Public methods
equals
open fun equals(other: Any?): Boolean
Compares this object against the specified object. The result is true
if and only if the argument is not null
and it represents the same interface address as this object.
Two instances of InterfaceAddress
represent the same address if the InetAddress, the prefix length and the broadcast are the same for both.
Parameters |
obj |
the object to compare against. |
Return |
Boolean |
true if the objects are the same; false otherwise. |
getAddress
open fun getAddress(): InetAddress!
Returns an InetAddress
for this address.
getBroadcast
open fun getBroadcast(): InetAddress!
Returns an InetAddress
for the broadcast address for this InterfaceAddress.
Only IPv4 networks have broadcast address therefore, in the case of an IPv6 network, null
will be returned.
Return |
InetAddress! |
the InetAddress representing the broadcast address or null if there is no broadcast address. |
getNetworkPrefixLength
open fun getNetworkPrefixLength(): Short
Returns the network prefix length for this address. This is also known as the subnet mask in the context of IPv4 addresses. Typical IPv4 values would be 8 (255.0.0.0), 16 (255.255.0.0) or 24 (255.255.255.0).
Typical IPv6 values would be 128 (::1/128) or 10 (fe80::203:baff:fe27:1243/10)
Return |
Short |
a short representing the prefix length for the subnet of that address. |
hashCode
open fun hashCode(): Int
Returns a hashcode for this Interface address.
Return |
Int |
a hash code value for this Interface address. |
toString
open fun toString(): String
Converts this Interface address to a String
. The string returned is of the form: InetAddress / prefix length [ broadcast address ].
Return |
String |
a string representation of this Interface address. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# InterfaceAddress\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nInterfaceAddress\n================\n\n```\nopen class InterfaceAddress\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.net.InterfaceAddress](#) |\n\nThis class represents a Network Interface address. In short it's an IP address, a subnet mask and a broadcast address when the address is an IPv4 one. An IP address and a network prefix length in the case of IPv6 address.\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Compares this object against the specified object. |\n| open [InetAddress](/reference/kotlin/java/net/InetAddress)! | [getAddress](#getAddress())`()` Returns an `InetAddress` for this address. |\n| open [InetAddress](/reference/kotlin/java/net/InetAddress)! | [getBroadcast](#getBroadcast())`()` Returns an `InetAddress` for the broadcast address for this InterfaceAddress. |\n| open [Short](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-short/index.html) | [getNetworkPrefixLength](#getNetworkPrefixLength())`()` Returns the network prefix length for this address. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](#hashCode())`()` Returns a hashcode for this Interface address. |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` Converts this Interface address to a `String`. |\n\nPublic methods\n--------------\n\n### equals\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun equals(other: Any?): Boolean\n```\n\nCompares this object against the specified object. The result is `true` if and only if the argument is not `null` and it represents the same interface address as this object.\n\nTwo instances of `InterfaceAddress` represent the same address if the InetAddress, the prefix length and the broadcast are the same for both.\n\n| Parameters ||\n|-------|--------------------------------|\n| `obj` | the object to compare against. |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if the objects are the same; `false` otherwise. |\n\n**See Also**\n\n- [java.net.InterfaceAddress#hashCode()](#hashCode()) \n\n### getAddress\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getAddress(): InetAddress!\n```\n\nReturns an `InetAddress` for this address.\n\n| Return ||\n|--------------------------------------------------------|-------------------------------------|\n| [InetAddress](/reference/kotlin/java/net/InetAddress)! | the `InetAddress` for this address. |\n\n### getBroadcast\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getBroadcast(): InetAddress!\n```\n\nReturns an `InetAddress` for the broadcast address for this InterfaceAddress.\n\nOnly IPv4 networks have broadcast address therefore, in the case of an IPv6 network, `null` will be returned.\n\n| Return ||\n|--------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| [InetAddress](/reference/kotlin/java/net/InetAddress)! | the `InetAddress` representing the broadcast address or `null` if there is no broadcast address. |\n\n### getNetworkPrefixLength\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getNetworkPrefixLength(): Short\n```\n\nReturns the network prefix length for this address. This is also known as the subnet mask in the context of IPv4 addresses. Typical IPv4 values would be 8 (255.0.0.0), 16 (255.255.0.0) or 24 (255.255.255.0).\n\nTypical IPv6 values would be 128 (::1/128) or 10 (fe80::203:baff:fe27:1243/10)\n\n| Return ||\n|--------------------------------------------------------------------------------|--------------------------------------------------------------------------|\n| [Short](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-short/index.html) | a `short` representing the prefix length for the subnet of that address. |\n\n### hashCode\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun hashCode(): Int\n```\n\nReturns a hashcode for this Interface address.\n\n| Return ||\n|----------------------------------------------------------------------------|-----------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this Interface address. |\n\n### toString\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\nConverts this Interface address to a `String`. The string returned is of the form: InetAddress / prefix length \\[ broadcast address \\].\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of this Interface address. |"]]