InetAddress ip;
try{
String name=InetAddress.getLocalHost().getHostName();
hn.setText(name);
ip=InetAddress.getLocalHost();
ipl.setText(ip.getHostAddress());
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
macl.setText(sb.toString());
}catch(Exception e){}
No comments:
Post a Comment