vasu devan wrote:At present I am putting the above command in a shell script and executing that in java.
Is there a way where I can directly use this command java.
I think you need to decide what you want. A shell script can certainly do the job, but it's a platform-specific solution.
My suggestion is: if you want to write it in Java, write it
all in Java; the language certainly has the ability to do what you want, but you
will have to read the entire file.
Rene's post has already shown you the basic method for reading lines. Have a look at
String.matches() and
String.split(), along with the
Pattern (java.util.regex.Pattern) and Matcher (java.util.regex.Matcher) classes.
Between them, they will do anything you can do with
grep (and probably quite a bit more).
Winston