要在終端excecute SENNA我用命令:Java的輸入輸出重定向流
senna.exe <input.txt> result.txt
現在我想在Java程序來實現這一點。這是到目前爲止我的代碼
ProcessBuilder builder = new ProcessBuilder("senna.exe");
builder.redirectErrorStream(true);
Process process = builder.start();
OutputStream stdin = process.getOutputStream();
InputStream stdout = process.getInputStream();
BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
writer.write("This is a test sentence");;
writer.flush();
String line;
while ((line = reader.readLine()) != null) {
System.out.println ("Stdout: " + line);
}
重定向我使用的代碼從this thread的輸入,輸出和錯誤流。問題是我收到以下錯誤消息:
FATAL ERROR: unable to open file hash/words.lst
我做錯了什麼?
我檢查了th文件路徑,但它不是錯誤消息的原因。 – MK14