Here you can find the source of getIPV4Address(List
private static String getIPV4Address(List<InterfaceAddress> addresses)
//package com.java2s; //License from project: Apache License import java.net.Inet4Address; import java.net.InterfaceAddress; import java.util.List; public class Main { /**/* ww w . j a v a2s. c o m*/ * Finds an ipv4 address in a list of interface addresses */ private static String getIPV4Address(List<InterfaceAddress> addresses) { for (InterfaceAddress interfaceAddress : addresses) { if (interfaceAddress.getAddress() instanceof Inet4Address) { return interfaceAddress.getAddress().getHostAddress(); } } return null; } }