You should read the entire file into a String and use the replace method for strings.
String (Java Platform SE 6)
Note that since you want to switch tags around you will need to create a temporary...