Latest topics
» JavaServer Faces (JSF)
Sat Sep 15, 2012 7:26 pm by vijayasarathy

» JAVA SERVERS
Wed Sep 12, 2012 6:34 pm by vijayasarathy

» 10 Best Java Web Development Frameworks
Wed Sep 12, 2012 6:18 pm by Prakash

» how to find hard disk serial details....
Thu Jul 05, 2012 1:08 pm by jagantech

» how to find MAC ID in windows using java
Thu Jul 05, 2012 1:03 pm by jagantech

» java server faces
Sat May 19, 2012 6:15 pm by jaganeshtech

» Oracle set to update analytics strategy, go after SAP customers
Sat Mar 24, 2012 12:06 pm by Naga

» Discovery over 'warp speed' planets
Sat Mar 24, 2012 12:32 am by plusinfomedia

» End of Java Era?
Sat Mar 24, 2012 12:03 am by plusinfomedia

External Links
External Links

how to find MAC ID in windows using java

Go down

how to find MAC ID in windows using java

Post  jagantech on Thu Jul 05, 2012 1:03 pm

package algorithm;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

/**
*
* @author New Destiny
*/
public class mac {
public String macstr() throws UnknownHostException, SocketException
{

String sss="";
InetAddress address = InetAddress.getLocalHost();


NetworkInterface ni =NetworkInterface.getByInetAddress(address);
if (ni != null) {
byte[] mac = ni.getHardwareAddress();





if (mac != null) {




StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {

// System.out.format("%02X%s", mac[i], (i < mac.length - 1)?"_":""+" ");


sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1)?"":""));






}



sss=sb.toString();


return sss;




}
}
return sss;


}

public static void main(String[] args)
{


mac macobj=new mac();
System.out.println("mac address:"+macobj.macstr());


}
}
[left]
Code:

jagantech

Posts : 2
Join date : 2012-07-05

View user profile

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum