public static String getLocalIp ( ) throws UnknownHostException { String preffered = System . getProperty ( PREFERED_ADDRESS_PROPERTY_NAME ) ; return chooseAddress ( preffered ) . getHostAddress ( ) ; }
Returns the local IP . It loops through the network interfaces and returns the first non loopback address