Java - general

Determine MAC-address

From JDK1.6 on, MAC-addresses let determine themselves very easy:


package com.sowas.javawiki;
 
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
 
public class MacAddress {
 
	public static void main(String args[]) throws SocketException {
		Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
		for (NetworkInterface netint : Collections.list(nets)) {
			System.out.println("name:        " + netint.getDisplayName());
			System.out.println("Mac-address: " + Arrays.toString(netint.getHardwareAddress()));
			System.out.println();
		}
	}
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007