Here you can find the source of getLoopbackAddress()
public static String getLoopbackAddress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getLoopbackAddress() { // InetAddress.getLoopbackAddress() is @since 1.7 //// www . ja va 2s .c o m // Aside from that, getLoopbackAddress() seems preferable to // InetAddress.getByName("localhost") since the former doesn't seem to // require the local resolver to be sane. //return InetAddress.getLoopbackAddress().getHostAddress(); try { return InetAddress.getByName("localhost").getHostAddress(); } catch (UnknownHostException e) { throw new RuntimeException(e); } } }