正则表达式匹配/data/misc/wifi/wpa_supplicant.conf的WiFi名称与密码:
String regex_name="ssid="(.*?)"";
String regex_psk="psk="(.*?)"";
核心代码:
Pattern
p_name=Pattern.compile(regex_name);
Pattern p_psk=Pattern.compile(regex_psk);
List<Wifi_bean> wifi=new ArrayList<Wifi_bean>();
Matcher m_name =
p_name.matcher(conf_wifi);
Matcher
m_psk=p_psk.matcher(conf_wifi);
while(m_name.find()){
wifi.add(new
Wifi_bean(m_name.group(),"=========="));
}
while(m_psk.find()){
wifi.add(new
Wifi_bean("----------", m_psk.group()));
}