判断device状态是否可以用
@Test
public void devices() throws Exception
{
Person p = new Person();
List<String> deviceslist = p.excmd(“adb devices”); //执行adb devices命令 并且存放的list集合中
List<String> devlist = new ArrayList<String>(); //定义一个个list集合存放判断后的结果,有可能多个
if (deviceslist.size() > 2) {
for (int i = 1;i < deviceslist.size() -1; i++) {
String len[] = deviceslist.get(i).split(“/t”); //split()分割函数
if (len[1].trim().equals(“device”)) {
devlist.add(len[0].trim()); //trim()去掉字符串首尾的空格 保存到list集合中去
}
}
}
else
{
System.out.println(“没有匹配的设备”);
}
for(String s:devlist) //通过foreach函数输出list集合内容
{
System.out.println(“设备号:” +s);
}
}
@Test
public void tirmeFunt()
{
String s = ” good good “;
String w = “good good”;
System.out.println(“判断s与w是否相等”+w.equals(s));
s = s.trim();
System.out.println(“去掉左右空格在判断是否相等:=============”);
System.out.println(“判断s与w是否相等”+w.equals(s));
String b = “111,333,4444,555,2555,66666,4444433,44223,3666”;
String[] a = b.split(“,”);
String p = null;
for(String i:a)
{
System.out.println(“输出结果是:”+i);
}
System.out.println(“合并结果”+p);
}
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/opensource/185800.html