-1
我在下面的代碼中嘗試獲取ran命令的輸出。但它打印空白。如何在Mac上運行終端命令並通過java打印輸出
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。
嘗試 '字符串CMD = 「DEVICE_ID -l」;' – jctim
,是不是在蘋果@jctim –
工作,我不知道該怎麼做你的命令做的,但我想'字符串CMD =「PS - ef「;'並在stdout中獲得輸出。也許你的命令在stderr中寫入? – jctim