Here you can find the source of getShortHostName()
public static String getShortHostName()
//package com.java2s; //License from project: Open Source License import java.net.*; public class Main { public static String getShortHostName() { String name = getHostName(); int i = name.indexOf('.'); if (i == -1) return name; return name.substring(0, i); }/*from ww w. ja v a 2s.co m*/ public static String getHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { return "(unknown)"; } } }