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 tag to change to and revert back
ex: replace <b> with <i>
//opening tags
fileContents.replaceAll("<b>","<@@>");
fileContents.replaceAll("<i>","<b>");
fileContents.replaceAll("<@@>","<i>");
//closing tags
fileContents.replaceAll("</b>","<@@>");
fileContents.replaceAll("</i>","</b>");
fileContents.replaceAll("<@@>","</i>");