I got a byte from an xml stream that i want to print to the screen,
this is not really a problem but there's a lot of whitespace in the end and i want it out.
the byte is always different but here's an example of the output
There are lots of things you could do.
If you get a zero-length line when reading from the file, you could simply ignore it.
If you get a line which is all whitespace, which you can easily find a regular expression for, again, you can ignore it.
You can match for whitespace at the end of the line with a similar regular expression and a line-end boundary match, and use the String.replace() or replaceAll() method on it.
I am sure there are lots of other things you can do. Anybody else got any ideas?
I am not convinced String#trim() is what you want, because it will take the leading whitespace out too, and you would lose your indentation.