code: public static String getLocalHostName() throws UnknownHostException {
          String preffered = System.getProperty(PREFERED_ADDRESS_PROPERTY_NAME);
          return chooseAddress(preffered).getHostName();
      }
docs: Returns the local hostname. It loops through the network interfaces and returns the first non loopback address
  
  @return
  @throws UnknownHostException