content: package pers.adlered.liteftpd.tool;
  
  import java.net.Inet4Address;
  import java.net.InetAddress;
  import java.net.NetworkInterface;
  import java.net.SocketException;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.List;
  
  /**
   * <h3>LiteFTPD-UNIX</h3>
   * <p>Get IP Address of the server.</p>
   *
   * @author : https://github.com/AdlerED
   * @date : 2019-09-19 09:21
   **/
  public class LocalAddress {
      public static List<String> getLocalIPList() {
          List<String> ipList = new ArrayList<String>();
          try {
              Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
              NetworkInterface networkInterface;
              Enumeration<InetAddress> inetAddresses;
              InetAddress inetAddress;
              String ip;
              while (networkInterfaces.hasMoreElements()) {
                  networkInterface = networkInterfaces.nextElement();
                  inetAddresses = networkInterface.getInetAddresses();
                  while (inetAddresses.hasMoreElements()) {
                      inetAddress = inetAddresses.nextElement();
                      if (inetAddress != null && inetAddress instanceof Inet4Address) {
                          ip = inetAddress.getHostAddress();
                          ipList.add(ip);
                      }
                  }
              }
          } catch (SocketException e) {
              e.printStackTrace();
          }
          return ipList;
      }
  }
  