Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Created April 9, 2020 05:56
Show Gist options
  • Save justdoit0823/fc41eddc3780dfed2671a595824b0b9f to your computer and use it in GitHub Desktop.
Save justdoit0823/fc41eddc3780dfed2671a595824b0b9f to your computer and use it in GitHub Desktop.
list network interfaces.
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