-3

Program including following code works on ubuntu but i am not friendly with ubuntu. I want to make it work in windows. In windows it is showing exception as grep is not windows command.can it be solved??

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);
}

}
user2394030
  • 41
  • 1
  • 4

2 Answers2

1

You should install grep program for windows. Something like this http://gnuwin32.sourceforge.net/packages/grep.htm

NullPointer
  • 924
  • 14
  • 27
0

You should look into FindStr, a built in Windows equivalent to grep.

quazzieclodo
  • 831
  • 4
  • 10