誰能幫我把這個代碼在linuxLinux的find命令不工作
public static void main(String[] args) throws Exception,{
String s ="find . -exec ls -al {} \\;";
Process exec = Runtime
.getRuntime()
.exec(s);
exec.waitFor();
System.out.println(s);
if (exec.getErrorStream().available() != 0) {
BufferedInputStream bf = new BufferedInputStream(
exec.getErrorStream());
DataInputStream din = new DataInputStream(bf);
System.out.println(din.readLine());
}
System.out.println(exec.exitValue());
}
我得到以下輸出工作。
find . -exec ls -al {} \;
find: missing argument to `-exec'
1
您正在從錯誤流打印。您可能需要該流程的標準輸出。 –
請看看http://stackoverflow.com/questions/14441652/get-process-output-without-blocking –
目前我有一個退出代碼1.我想退出代碼0(成功)。我正在打印錯誤流,因爲我的退出代碼爲1(失敗)。你們中的任何人都得到了這個代碼工作與退出代碼0,讓我知道。 – user2288031