You need to access the main writer, who is the author that you decorated with XMLStreamWriter (I hope if he is, he will be the author that you passed to createXMLStreamWriter() ), or you need to temporarily disable escaping, which depends on the implementation.
The reason you get weird characters is because the XMLStreamWriter has no idea where you write these characters, so the default attribute is an XML attribute that is more restrictive than the element (content) . Derivation is also usually based on CharacterEncoder . I assume that in older versions of Java, it did not escape XML elements that did not go out of white space, such as newlines, or use a different character encoding. I understand why they fixed it, since it is clear that escaping is the right way to do this. I also don't know which XMLStreamWriter or CharacterEncoder yours is actually using, and it is more likely that the default XMLStreamWriter or character encoding implementation has changed (you should check the debugger that is selected).
No matter if you access the main writer, you can simply write the characters directly and they will not be escaped. However, make sure that the author you are using is the one that was decorated, and not one deeper (i.e. if you have a BufferWriter decorating FileWriter, use BufferWriter).
For those who don't think writeCharacters does escaping, you can see the code .
EDIT
In truth, after looking at the code, you can just call writer.setEscapeCharacters(false) by default sun impl (unfortunately, you probably have to do a few castings) before you call writeCharacters , which is probably better than getting the original the author. I did not know about this flag.
EDIT 2
Another possible quick fix, if you hope to use the Sun StaX implementation, is to change the character encoding at the system level and choose the encoding so that the CRLF does not slip away ideally before the JDK update. It is suggested that the problem may be that your character encoding changed from Windows or ISO to UTF-8 when upgrading Java, but I cannot be sure, since you did not specify your operating system. If it has not changed during the upgrade (i.e., we hope that you have not always performed UTF-8), then ignore this option.
EDIT 3
After some testing, I'm pretty sure that the StaX implementation is not the default Java Sun implementation, but probably Woodstox . I have not tested Woodstox, but it looks like the library is still a little space-savvy for performance reasons and seems to have different rules if its UTF-8 and ISO (again character encoding).