New Destiny
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Latest topics
» JavaServer Faces (JSF)
how to find MAC ID in windows using java EmptySat Sep 15, 2012 7:26 pm by vijayasarathy

» JAVA SERVERS
how to find MAC ID in windows using java EmptyWed Sep 12, 2012 6:34 pm by vijayasarathy

» 10 Best Java Web Development Frameworks
how to find MAC ID in windows using java EmptyWed Sep 12, 2012 6:18 pm by Prakash

» how to find hard disk serial details....
how to find MAC ID in windows using java EmptyThu Jul 05, 2012 1:08 pm by jagantech

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

» java server faces
how to find MAC ID in windows using java EmptySat May 19, 2012 6:15 pm by jaganeshtech

» Oracle set to update analytics strategy, go after SAP customers
how to find MAC ID in windows using java EmptySat Mar 24, 2012 12:06 pm by Naga

» Discovery over 'warp speed' planets
how to find MAC ID in windows using java EmptySat Mar 24, 2012 12:32 am by plusinfomedia

» End of Java Era?
how to find MAC ID in windows using java EmptySat 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 Empty how to find MAC ID in windows using java

Post  jagantech 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

Back to top Go down

Back to top


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