try { return InetAddress.getByName("localhost").getHostAddress(); } catch (UnknownHostException e) { throw new RuntimeException(e);
try { for (NetworkInterface netIf : Collections.list(NetworkInterface.getNetworkInterfaces())) { if (netIf == null) { continue; if (netIf.isLoopback()) { Enumeration<InetAddress> addrs = netIf.getInetAddresses(); while (addrs.hasMoreElements()) { ...