我在使.getruntime.exec()正常工作時遇到了一些問題。下面是處理該部分的代碼:Java Runtime.getRuntime()非法參數異常
while (line != null)
{
String name = line;
String commandFull = commandFirst + name + commandLast;
String[] fullCommand = new String[] {commandFirst, name, commandLast};
for(int i=0;i<3;i++)
{
System.out.print(fullCommand[i]);
}
Runtime runner = Runtime.getRuntime();
Process p = runner.exec(fullCommand);
outFile.println(fullCommand);
line = inFile.readLine();
}
它打印出它應該看起來的命令。當我在這裏運行程序時,輸出是:
adfind -b dc=stuff,dc=com -f "cn=user" |find "displayName" >> fullList.txt
Exception in thread "main" java.lang.IllegalArgumentException
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at lookup.main(lookup.java:41)