Java IP Address Get getIPV4Address(List addresses)

Here you can find the source of getIPV4Address(List addresses)

Description

Finds an ipv4 address in a list of interface addresses

License

Apache License

Declaration

private static String getIPV4Address(List<InterfaceAddress> addresses) 

Method Source Code


//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;
    }
}

Related

  1. getIPList(String address)
  2. getIPList(String s, String s1)
  3. getIPs()
  4. getIPs()
  5. getIPv4Address()
  6. getIPv4Address(NetworkInterface iface)
  7. getIPV4MainAddress(NetworkInterface ni)
  8. getIPv4MulticastGroup(int hash)
  9. getIPV4NetwprkOrder(String theIp)