public class XCRunUtil {
ProcessBuilder processBuilder = new ProcessBuilder();
Process process;
public void execute(String url) {
String link = "xcrun simctl list devices";
System.out.println("link : " + link);
processBuilder.command("sh", "-c", link);
try {
process = processBuilder.start();
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
System.out.println("Here is the standard output of the command:\n");
String s = null;
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// Read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
This above code will works