Here you can find the source of getAvailableNetworkInterface()
public static NetworkInterface getAvailableNetworkInterface()
//package com.java2s; /*/* w w w . jav a 2 s . c o m*/ * Copyright Siemens AG, 2015. Part of the SW360 Portal Project. * * SPDX-License-Identifier: EPL-1.0 * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.net.NetworkInterface; import java.net.SocketException; import java.util.*; public class Main { public static NetworkInterface getAvailableNetworkInterface() { try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement(); if (networkInterface.isLoopback()) continue; if (networkInterface.isUp()) return networkInterface; } return null; } catch (SocketException e) { return null; } } }