Java version of grep. For CMPS12B assignment 1.