Mac Java execute ADB devices command
Recently in doing Mac+appium automation need to get mobile device ID through Java, through the code needed to obtain;
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"; Where the SDK is located
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");
}
}
This article is from the "Know the Ming" blog, please be sure to keep this source http://357712148.blog.51cto.com/6440370/1976023
Mac Java execute ADB devices command