removing duplicate whitespace

Basically i've got some code below which removes all the whitespace from a text file.

Originally it read through the whole file line by line, but this can take forever as some of the files that i'm dealing with can be quite large.

What i want the program to do is just remove the white space from the xml tag headers and not the whole file. For instance the tags appear as < t a g >< / t a g > instead of the normal way <tag></tag> which is a problem when i'm trying to use DOMParse to get the xml from the file.

As you can see from the code i added in the line

Java Code:

if (strLine.contains("< M D R - D V D >"))

This was just to see if the program would pick up the that particular tag which it did, however my file has loads of different tags.

My question is, is there any way of modifying the code to make the program pull all the tag names using a single line of code without having to enter every single tag name?

I have a few other questions, but i'll get this one out of the way first.

This is one of those things that sounds simplistic, but is really very difficult to program. Your best bet is to use String.split("<") to determine where the tags begin, add the '<' back onto the beginning of each String in the array that is returned, and then use String.split(">") to determine the end of the tag, adding the '>' char back onto the end of the FIRST String in the returned array. You will then have numerous arrays of Strings, with the first String of each array being a tag. After removing the whitespaces from the String, you can put all the Strings back together into the original string. e.g