我已经检查了许多关于运行外部程序的线程,但它们无法解决我的问题。为了运行 Siesta(DFT 计算),我必须使用类似这样的东西(Si.fdf 是输入文件): siesta < Si.fdf 我正在使用以下代码:
public static void main(String argv[]) throws IOException {
Runtime r = Runtime.getRuntime();
Process p;
BufferedReader is;
String line;
System.out.println("siesta < Si.fdf");
p = r.exec("siesta < Si.fdf");
System.out.println("In Main after exec");
is = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = is.readLine()) != null)
System.out.println(line);
System.out.println("In Main after EOF");
System.out.flush();
try {
p.waitFor();
} catch (InterruptedException e) {
System.err.println(e); //
return;
}
System.err.println("Process done, exit status was " + p.exitValue());
return;
}
但此代码仅在没有任何输入文件的情况下运行 Siesta。