程序包括下面的代码在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);
}
}
你有没有考虑过使用[cygwin](http://cygwin.com/)。可能的重复[什么是适用于Windows的良好grep工具?](http://stackoverflow.com/q/87350/2970947) –
是'grep' Linux自带的一个命令/程序?它有什么作用? –