Also, "cat filename.log | grep success" is not one process. It's one process ("grep success") that is using the output of another process ("cat filename.log") as its input. This is handled by the shell (BASH, KSH, CSH etc) usually. When doing this in Java you need to do this yourself.
I see some options:
1) copy the contents of the input stream of the first process to the output stream of the second process, then read the input of the second process:
2) replace the catting with a Java input stream:
3) replace it all with Java code:
If the regex becomes a little more complex you can use java.util.regex.Pattern instead of the contains method.
Personally, I would go for option three. If you don't, read
this first.