Here you can find the source of getLocalAddress(String adaptorName)
private static InetAddress getLocalAddress(String adaptorName)
//package com.java2s; //License from project: Apache License import java.net.*; import java.util.Enumeration; public class Main { private static InetAddress getLocalAddress(String adaptorName) { try {/* ww w.j av a 2 s . c o m*/ Enumeration<NetworkInterface> b = NetworkInterface.getNetworkInterfaces(); while (b.hasMoreElements()) { NetworkInterface networkInterface = b.nextElement(); if (networkInterface.getName().equals(adaptorName)) { for (InterfaceAddress f : networkInterface.getInterfaceAddresses()) { if (f.getAddress().isSiteLocalAddress()) { return f.getAddress(); } } } } } catch (SocketException e) { e.printStackTrace(); } return null; } }