请帮助我找出哪个函数用于在目标 c 中运行终端命令,就像我在以下代码中的 java 中使用的那样。我只想知道 obj c 或 cocoa 中使用哪个函数来执行终端进程。
Runtime rt = Runtime.getRuntime();
Process prcComile = rt.exec("javac -d F:/ F://" + fname.getText()+ ".java");
InputStream iscmp = prcComile.getErrorStream();
int cerrInt = iscmp.read();
if (cerrInt == -1) {
Process prc = rt.exec("java -cp F:/ " +fname.getText());
InputStream iserr = prc.getErrorStream();
int errInt = iserr.read();
if (errInt == -1) {
InputStream is = prc.getInputStream();
int readInt = is.read();
String allOutput = "";
while (readInt != -1) {
char ch = (char) readInt;
allOutput = allOutput + ch;
readInt = is.read();
}
txtOutput.setText(allOutput);
} else {
String errorString = "";
while (errInt != -1) {
char ch = (char) errInt;
errorString += ch;
errInt = iserr.read();
}
txtOutput.setText(errorString);
}
} else {
String errorString = "";
while (cerrInt != -1) {
char ch = (char) cerrInt;
errorString += ch;
cerrInt = iscmp.read();
}
txtOutput.setText(errorString);
}