public class NetworkUtils extends Object
Constructor and Description |
---|
NetworkUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
getLocalHostName() |
static String |
getLocalIpAddress() |
static String |
replaceHostName(String addr)
Replace and resolve the hostname in a given address or path string.
|
static String |
resolveHostName(String hostname)
Resolve a given hostname by a canonical hostname.
|
public static String getLocalHostName()
public static String getLocalIpAddress()
public static String replaceHostName(String addr) throws UnknownHostException
addr
- an address or path string, e.g., "hdfs://host:port/dir", "file:///dir", "/dir".UnknownHostException
- if the hostname cannot be resolved.public static String resolveHostName(String hostname) throws UnknownHostException
hostname
- the input hostname, which could be an alias.UnknownHostException
- if the given hostname cannot be resolved.Copyright © 2014. All rights reserved.