我尝试使用下面的代码来获取ran命令的输出。但它打印空了。
String cmd = "/bin/bash device_id -l";
Process process = Runtime.getRuntime.exec(cmd);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
有谁可以帮助我。我必须得到连接的iDevice UDID。
答案 0 :(得分:1)
使用以下代码,我可以获得连接的设备udid。
public String deviceUDID() throws IOException{
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "/usr/local/bin/idevice_id -l");
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
line = r.readLine();
System.out.println(line);
return line;
}