-
public interface NetUtilCreated by kurila on 11.07.16.
-
-
Method Summary
Static Methods Modifier and Type Method Description static java.lang.StringaddPortIfMissing(java.lang.String addr, int defaultPort)static java.net.InetAddressgetHostAddr()Tries to resolve 1st enabled external network interface IP address.static longgetHostAddrCode()static java.lang.StringgetHostAddrString()
-
-
-
Method Detail
-
getHostAddr
static java.net.InetAddress getHostAddr() throws java.net.SocketExceptionTries to resolve 1st enabled external network interface IP address. Tries to fall back to loopback interface if no valid external interface found.- Returns:
- IP address
- Throws:
java.net.SocketException- if failed to resolve an interface addressjava.lang.IllegalStateException- if no network interface found
-
getHostAddrString
static java.lang.String getHostAddrString() throws java.net.SocketException, java.lang.IllegalStateException- Throws:
java.net.SocketExceptionjava.lang.IllegalStateException
-
getHostAddrCode
static long getHostAddrCode() throws java.net.SocketException, java.lang.IllegalStateException- Throws:
java.net.SocketExceptionjava.lang.IllegalStateException
-
addPortIfMissing
static java.lang.String addPortIfMissing(java.lang.String addr, int defaultPort)
-
-