【发布时间】:2012-07-26 11:35:23
【问题描述】:
基本上,当我在 手动终端,sift 程序工作并写入一个 .key 文件,但是当我尝试从我的程序中调用它时,没有写入任何内容。
我是否正确使用了 exec() 方法?我查看了 API,但似乎找不到哪里出错了。
public static void main(String[] args) throws IOException, InterruptedException
{
//Task 1: create .key file for the input file
String[] arr = new String[3];
arr[0] = "\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/siftWin32.exe\"";
arr[1] = "<\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/cover_actual.pgm\"";
arr[2] = ">\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/keys/cover_actual.key\"";
String command = (arr[0]+" "+arr[1]+" "+arr[2]);
Process p=Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
}
}
【问题讨论】:
-
你得到了什么错误??
-
我没有收到任何错误,但它也没有像预期的那样写入 .key 文件。
-
您确定可以将输出重定向与
Runtime.exec一起使用吗?