Suppose i have to filter some text from a file. Then i have 2 solutions
- Either I take all the contents of file into a single variable(like fileinputstream or something else) which can be parsed using regular expression.
- Or i use looping to read file line by line. Then i apply either regular expression or some string function on each line.
Which method will be better and faster?