2013-11-27 22 views
-3

程序包括下面的代碼在Ubuntu上工作,但我不友好的Ubuntu的我想使它工作在Windows在Windows它顯示異常作爲grep的不窗戶command.can它來解決?是否有任何方法可以刪除java.io.IOException:無法在windows中運行程序「grep」:CreateProcess error = 2「

for(int i=0;i<list.size();i++) 
{ 
    //System.out.println(list.get(i)); 

    try{ 
    str="grep -c -w "+ list.get(i) +" 1.txt"; 

    Process p=Runtime.getRuntime().exec(str); 

BufferedReader in1=new BufferedReader(new InputStreamReader(p.getInputStream())); 
    int line=Integer.parseInt(in1.readLine()); 

    if(line==0){ 
    b="0,".getBytes(); 
    out.write(b);  
    } 

    else{ 
    b="1,".getBytes(); 
    out.write(b);  
    } 

}catch(Exception e){ 
System.out.println(e); 
} 

} 
+0

你有沒有考慮過使用[cygwin](http://cygwin.com/)。可能的重複[什麼是適用於Windows的良好grep工具?](http://stackoverflow.com/q/87350/2970947) –

+0

是'grep' Linux自帶的一個命令/程序?它有什麼作用? –

回答

相關問題