I have the following code on a Windows machine:
for(Enumeration enm = NetworkInterface.getNetworkInterfaces(); enm.hasMoreElements();){
NetworkInterface network = (NetworkInterface) enm.nextElement();
if(null != network.getHardwareAddress()){
return EthernetAddress.valueOf(network.getHardwareAddress());
}
}
This fails because the network.getHardwareAddress() returns an empty byte array, instead of null as stated in the javadocs for NetworkInterface. Does anyone know why this may happen?