A grep-like tool in java