Here you can find the source of getAllInterfaces()
Parameter | Description |
---|---|
SocketException | an exception |
private static List<NetworkInterface> getAllInterfaces() throws SocketException
//package com.java2s; //License from project: Apache License import java.net.NetworkInterface; import java.net.SocketException; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class Main { /**/* w w w .j av a 2s .com*/ * Get all interfaces, including virtual interfaces. * @return A list of all interfaces * @throws SocketException */ private static List<NetworkInterface> getAllInterfaces() throws SocketException { List<NetworkInterface> allInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces()).stream() .flatMap(m -> { List<NetworkInterface> l = Collections.list(m.getSubInterfaces()); l.add(m); return l.stream(); }).collect(Collectors.toList()); return allInterfaces; } }