title: Android API-23: InetAddressUtils replacement
body: <p>Switching to Android Marshmallow API, I was using <code>org.apache.http.conn.util.InetAddressUtils</code> for <code>InetAddressUtils.isIPv4Address(ipAddress)</code> in a code to list all IPs from a device.</p>
  
  <p>As part of the <a href="https://developer.android.com/sdk/api_diff/23/changes.html">API-23 changes</a>, the <code>InetAddressUtils</code> class is now gone.</p>
  
  <p>How can I replace the below code now?</p>
  
  <pre><code>public static String ipAddress() {
      try {
          for (final Enumeration&lt;NetworkInterface&gt; enumerationNetworkInterface = NetworkInterface.getNetworkInterfaces(); enumerationNetworkInterface.hasMoreElements();) {
              final NetworkInterface networkInterface = enumerationNetworkInterface.nextElement();
              for (Enumeration&lt;InetAddress&gt; enumerationInetAddress = networkInterface.getInetAddresses(); enumerationInetAddress.hasMoreElements();) {
                  final InetAddress inetAddress = enumerationInetAddress.nextElement();
                  final String ipAddress = inetAddress.getHostAddress();
                  if (! inetAddress.isLoopbackAddress() &amp;&amp; InetAddressUtils.isIPv4Address(ipAddress)) {
                      return ipAddress;
                  }
              }
          }
          return null;
      }
      catch (final Exception e) {
          LogHelper.wtf(null, e);
          return null;
      }
  }
  </code></pre>