我正在尝试从已编译和执行的 Java 代码执行 C 代码,但是,我没有从可执行文件中获得任何输出。谁能帮我完成这个任务?
代码如下。
public class Test {
public static void main(String args[]) {
try {
Process processCompile = Runtime.getRuntime().exec("e:/Sample.exe");
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
最佳答案
试试这个:
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(processCompile .getInputStream()));
// read the output from the command
System.out.println("EXE OUTPUT");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
关于java - 从 Java 代码调用 C 可执行文件后没有得到任何输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16621472/