public class NetUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ANYHOST |
static String |
LOCALHOST |
| Constructor and Description |
|---|
NetUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
filterLocalHost(String host) |
static int |
getAvailablePort() |
static int |
getAvailablePort(int port) |
static String |
getHostName(String address) |
static String |
getIpByHost(String hostName) |
static InetAddress |
getLocalAddress()
Find first valid IP from local network card
|
static String |
getLocalHost() |
static InetSocketAddress |
getLocalSocketAddress(String host,
int port) |
static int |
getRandomPort() |
static boolean |
isAnyHost(String host) |
static boolean |
isInvalidLocalHost(String host) |
static boolean |
isInvalidPort(int port) |
static boolean |
isLocalHost(String host) |
static boolean |
isValidAddress(String address) |
static boolean |
isValidLocalHost(String host) |
static void |
joinMulticastGroup(MulticastSocket multicastSocket,
InetAddress multicastAddress) |
static void |
setInterface(MulticastSocket multicastSocket,
boolean preferIpv6) |
static InetSocketAddress |
toAddress(String address) |
static String |
toAddressString(InetSocketAddress address) |
static String |
toURL(String protocol,
String host,
int port,
String path) |
public static final String LOCALHOST
public static final String ANYHOST
public static int getRandomPort()
public static int getAvailablePort()
public static int getAvailablePort(int port)
public static boolean isInvalidPort(int port)
public static boolean isValidAddress(String address)
public static boolean isLocalHost(String host)
public static boolean isAnyHost(String host)
public static boolean isInvalidLocalHost(String host)
public static boolean isValidLocalHost(String host)
public static InetSocketAddress getLocalSocketAddress(String host, int port)
public static String getLocalHost()
public static InetAddress getLocalAddress()
public static String getIpByHost(String hostName)
hostName - public static String toAddressString(InetSocketAddress address)
public static InetSocketAddress toAddress(String address)
public static void joinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress) throws IOException
IOExceptionpublic static void setInterface(MulticastSocket multicastSocket, boolean preferIpv6) throws IOException
IOExceptionCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.