Android examples for java.net:Mac Address
get Mac address by reading /sys/class/net/wlan0/address
import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; public class Main { static String getMac() { String macSerial = ""; String str = ""; try {//from w w w . jav a2s . co m Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address "); InputStreamReader ir = new InputStreamReader(pp.getInputStream()); LineNumberReader input = new LineNumberReader(ir); for (; null != str;) { str = input.readLine(); if (str != null) { macSerial = str.trim(); break; } } } catch (IOException ex) { ex.printStackTrace(); } return macSerial; } }