import java.io.*;public class Mac{
public static void main(String[] arg){
try{
java.lang.Process proc = Runtime.getRuntime().exec("ipconfig /all");
InputStream istr = proc.getInputStream();
byte[] data = new byte[1024];
istr.read(data);
String netdata = new String(data);
System.out.println("Your Mac Address="+procAll(netdata));
}catch(IOException e){
System.out.println("error="+e);
}
}
public static String procAll(String str){
return procStringEnd(procFirstMac(procAddress(str)));
}
public static String procAddress(String str){
int indexof = str.indexOf("Physical Address");
if(indexof>0)
return str.substring(indexof,str.length());
return str;
}
public static String procFirstMac(String str){
int indexof = str.indexOf(":");
if(indexof>0)
return str.substring(indexof+1,str.length()).trim();
return str;
}
public static String procStringEnd(String str){
int indexof = str.indexOf("\r");
if(indexof>0)
return str.substring(0,indexof).trim();
return str;
}
}