Java IP Address Get getWinLocalIP()

Here you can find the source of getWinLocalIP()

Description

get Win Local IP

License

Apache License

Declaration

public static String getWinLocalIP() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.*;

import java.util.Enumeration;

public class Main {
    public static String getWinLocalIP() {
        String ip = "";
        try {/*from ww w  .  j  a v a 2  s  .c o  m*/
            Enumeration<?> e1 = (Enumeration<?>) NetworkInterface.getNetworkInterfaces();
            while (e1.hasMoreElements()) {
                NetworkInterface ni = (NetworkInterface) e1.nextElement();
                Enumeration<?> e2 = ni.getInetAddresses();
                while (e2.hasMoreElements()) {
                    InetAddress ia = (InetAddress) e2.nextElement();
                    ip = ia.getHostAddress();
                }
            }
        } catch (SocketException e) {
            e.printStackTrace();
        }
        return ip;
    }
}

Related

  1. getPublicIPAddress()
  2. getPublicIps()
  3. getPublicIpViaHttp()
  4. getStrLocalIP()
  5. getVisibleIp()
  6. getWinLocalIp()