Java examples for Network:Network Address
get My Host Name from InetAddress
//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(getMyHostName()); }// w ww.j a v a2s.c om public static String getMyHostName() throws UnknownHostException { return getMyAddress().getHostName(); } public static InetAddress getMyAddress() throws UnknownHostException { return InetAddress.getLocalHost(); } }