mac java执行adb devices命令
最近在做mac+appium自动化需要通过java获取手机设备id,通过代码需要这样才能获得;
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”; //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”);
}
}
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/185974.html