What is the fastest way to do a search and replace on a string in an existing file using Java?
Let's say I have this:
// This references an existing file File file = ... The file in question looks like this:
The Green Dog is furry. It likes to run in the Green Grass. Green is its favorite color. How would I go about replacing the String "Green" with "Blue" and having that file re-saved with the new color?
Update: I've thought about this a little more and perhaps the best and fastest way is to just read the contents of the file into a string (using something like FileUtils) and then just doing a replace and re-writing to the file?