Mendapatkan Mac Address dengan Java

Untuk mendapatkan Mac Address dengan Java bisa dicoba perintah berikut ini :


try {
InetAddress address = InetAddress.getLocalHost();

NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) {
byte[] mac = ni.getHardwareAddress();
if (mac != null) {
System.out.print("Data MAC Address dari " + address + " adalah ");
for (int i = 0; i < mac.length; i++) {
System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
}
System.out.println();
} else {
System.out.println("Address null");
}
} else {
System.out.println("Network Interface tidak ditemukan.");
}
} catch (Exception e) {
} <strong></strong>

&nbsp;

 

Semoga Membantu, Happy coding.. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: