Class NetworkInterfaceUtil

  • All Implemented Interfaces:

    
    public class NetworkInterfaceUtil
    
                        

    Utility class for network interface related functionality.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Optional<InetAddress> getFirstIpV4Address(NetworkInterface networkInterface) Loops through a network interface's addresses and returns the first one that matches an IPv4 address.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NetworkInterfaceUtil

        NetworkInterfaceUtil()
    • Method Detail

      • getFirstIpV4Address

         Optional<InetAddress> getFirstIpV4Address(NetworkInterface networkInterface)

        Loops through a network interface's addresses and returns the first one that matches an IPv4 address.

        Parameters:
        networkInterface - the network interface where to seek for an IPv4 address.
        Returns:

        the first found IPv4 address or empty if there is no IPv4 address connected to the network interface.