Java examples for Network:Host
local Canonical Host Name
//package com.java2s; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static void main(String[] argv) throws Exception { System.out.println(localFqdn()); }/* w ww. j a va2s .c om*/ public static String localFqdn() { try { return InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { return null; } } }