Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Java starts the dos command to collect notes two

Shulou Source: shulou.com Published: 2022-06-03 07:59:02 09月23日 Update

Determine whether the device state is available

@ Test

Public void devices () throws Exception

{

Person p = new Person ()

List deviceslist = p.excmd ("adb devices"); / / execute the adb devices command and store it in the list collection

List devlist = new ArrayList (); / / define one list collection to store the judged results, possibly multiple

If (deviceslist.size () > 2) {

For (int I = 1 + I < deviceslist.size ()-1 + +) {

String len [] = deviceslist.get (I) .split ("\ t"); / / split () split function

If (len [1] .trim () .equals ("device")) {

Devlist.add (len [0] .trim ()); / / trim () remove the leading and trailing spaces of the string and save them in the list collection

}

}

}

Else

{

System.out.println ("No matching devices")

}

For (String s:devlist) / / output the contents of the list collection through the foreach function

{

System.out.println ("device number:" + s)

}

}

@ Test

Public void tirmeFunt ()

{

String s = "good good"

String w = "good good"

System.out.println ("judge whether s and w are equal" + w.equals (s))

S = s.trim ()

System.out.println ("remove the left and right spaces to determine whether they are equal: =")

System.out.println ("judge whether s and w are equal" + w.equals (s))

String b = "111, 333, 444, 555, 2555, 6666, 44443, 44223, 3666"

String [] a = b.split (",")

String p = null

For (String iVLA)

{

System.out.println ("output result is:" + I)

}

System.out.println ("merger result" + p)

}

Tags: Result function space device output command content multiple character string status head and tail note Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei Redmi Docker Shulou Information