Stay organized with collections
Save and categorize content based on your preferences.
InetAddresses
open class InetAddresses
Utility methods for InetAddress
implementations.
Summary
Public methods |
open static Boolean |
Checks to see if the address is a numeric address (such as "192.0.2.1" or "2001:db8::1:2" ).
|
open static InetAddress |
Returns an InetAddress corresponding to the given numeric address (such as "192.168.0.1" or "2001:4860:800d::68" ).
|
Public methods
isNumericAddress
open static fun isNumericAddress(address: String): Boolean
Checks to see if the address
is a numeric address (such as "192.0.2.1"
or "2001:db8::1:2"
).
A numeric address is either an IPv4 address containing exactly 4 decimal numbers or an IPv6 numeric address. IPv4 addresses that consist of either hexadecimal or octal digits or do not have exactly 4 numbers are not treated as numeric.
This method will never do a DNS lookup.
Parameters |
address |
String: the address to parse. This value cannot be null . |
Return |
Boolean |
true if the supplied address is numeric, false otherwise. |
parseNumericAddress
open static fun parseNumericAddress(address: String): InetAddress
Returns an InetAddress corresponding to the given numeric address (such as "192.168.0.1"
or "2001:4860:800d::68"
).
See isNumericAddress(java.lang.String)
(String)} for a definition as to what constitutes a numeric address.
This method will never do a DNS lookup.
Parameters |
address |
String: the address to parse, must be numeric. This value cannot be null . |
Exceptions |
java.lang.IllegalArgumentException |
if address is not a numeric 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,["# InetAddresses\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nInetAddresses\n=============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/InetAddresses \"View this page in Java\") \n\n```\nopen class InetAddresses\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.InetAddresses](#) |\n\nUtility methods for [InetAddress](../../java/net/InetAddress.html#) implementations.\n\nSummary\n-------\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isNumericAddress](#isNumericAddress(kotlin.String))`(`address:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Checks to see if the `address` is a numeric address (such as `\"192.0.2.1\"` or `\"2001:db8::1:2\"`). |\n| open static [InetAddress](../../java/net/InetAddress.html#) | [parseNumericAddress](#parseNumericAddress(kotlin.String))`(`address:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Returns an InetAddress corresponding to the given numeric address (such as `\"192.168.0.1\"` or `\"2001:4860:800d::68\"`). |\n\nPublic methods\n--------------\n\n### isNumericAddress\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun isNumericAddress(address: String): Boolean\n```\n\nChecks to see if the `address` is a numeric address (such as `\"192.0.2.1\"` or `\"2001:db8::1:2\"`).\n\nA numeric address is either an IPv4 address containing exactly 4 decimal numbers or an IPv6 numeric address. IPv4 addresses that consist of either hexadecimal or octal digits or do not have exactly 4 numbers are not treated as numeric.\n\nThis method will never do a DNS lookup.\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------------------------------------------|\n| `address` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the address to parse. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|-----------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the supplied address is numeric, false otherwise. |\n\n### parseNumericAddress\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun parseNumericAddress(address: String): InetAddress\n```\n\nReturns an InetAddress corresponding to the given numeric address (such as `\"192.168.0.1\"` or `\"2001:4860:800d::68\"`).\n\nSee [isNumericAddress(java.lang.String)](#isNumericAddress(kotlin.String)) (String)} for a definition as to what constitutes a numeric address.\n\nThis method will never do a DNS lookup.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `address` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the address to parse, must be numeric. This value cannot be `null`. |\n\n| Return ||\n|-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| [InetAddress](../../java/net/InetAddress.html#) | an [InetAddress](../../java/net/InetAddress.html#) instance corresponding to the address. This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|----------------------------------------|\n| `java.lang.IllegalArgumentException` | if `address` is not a numeric address. |"]]