Here you can find the source of getIPAddress(NetworkInterface e)
public static String getIPAddress(NetworkInterface e)
//package com.java2s; //License from project: LGPL import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; public class Main { public static String getIPAddress(NetworkInterface e) { Enumeration<InetAddress> a = e.getInetAddresses(); for (; a.hasMoreElements();) { InetAddress addr = a.nextElement(); //IPv6 addr = a.nextElement(); //IPv4 return addr.getHostAddress(); }//from w w w. ja v a 2 s . c om return null; } }