Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mac java executes the adb devices command

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Mac java executes the adb devices command

Recently, when you are doing mac+appium automation, you need to obtain the id of mobile devices through java, and you need to get it through code.

Import java.io.BufferedReader

Import java.io.IOException

Import java.io.InputStream

Import java.io.InputStreamReader

Import java.io.LineNumberReader

Import java.util.List

Public class Tet {

Public static void main (String [] args) {

Process process = null

String osName = System.getProperty ("os.name

")

String command = "/ Users/zhouhaijun/androidsdk/android-sdk-macosx/platform-tools/adb devices"; / / location of sdk

Try

{

Process=Runtime.getRuntime () exec (command)

InputStreamReader ir = new InputStreamReader (process.getInputStream ())

LineNumberReader input= new LineNumberReader (ir)

String line

While ((line=input.readLine ())! = null)

System.out.println (line)

}

Catch (IOException e) {

System.err.println ("IOException" + e.getMessage ())

}

System.out.println (osName+ "/ n")

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report