1.通过命令获取
//获取本机的以太网mac地址
public String getLocalMac(boolean isRoot,String[] commands) {
Process mProc = null;
String result = "";
String line = "";
StringBuffer macSb = new StringBuffer();
DataOutputStream os = null;
try {
mProc = Runtime.getRuntime().exec(isRoot ? "su" : "sh");
os = new DataOutputStream(mProc.getOutputStream());
for (String command : commands) {
if (command == null) continue;
os.write(command.getBytes());
os.writeBytes(LINE_SEP);
os.flush();
}
os.writeBytes("exit" + LINE_SEP);
os.flush();
InputStreamReader is = new InputStreamReader(mProc.getInputStream());
BufferedReader br = new BufferedReader(is);
//执行命令cmd,只取结