Here you can find the source of resolveHostname()
private static String resolveHostname()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { private static String resolveHostname() { InetAddress addr;//w ww. j a v a 2 s. co m try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException uhe) { return "localhost"; } return addr.getCanonicalHostName(); } }