Created
April 9, 2020 05:56
-
-
Save justdoit0823/fc41eddc3780dfed2671a595824b0b9f to your computer and use it in GitHub Desktop.
list network interfaces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.NetworkInterface; | |
import java.util.Enumeration; | |
public class ListInterfaces { | |
public static void main(String[] args) { | |
try { | |
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | |
while (interfaces.hasMoreElements()) { | |
System.out.println("interface " + interfaces.nextElement().getName()); | |
} | |
} catch (Exception e) { | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment