I would like to search a .java file using Regular Expressions and I wonder if there is a way to detect one what lines in the file the matches are found.
There are no methods in Java that will do it for you. You must read the file line-by-line and check for a match on each line. You can keep an index of the lines as you read them and do whatever you want with that index when a match is found.