How to prevent STAX from converting \r\n to \n
843834May 13 2010 — edited May 16 2010In the code fragment below:
try {
XMLInputFactory f = XMLInputFactory.newInstance();
f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); // handle CDATA
} catch (Exception e) {
...
}
try {
rXMLStreamReader r = fXMLInputFactory.createXMLStreamReader(
new FileInputStream(filename)); // create stream reader
e = r.next();
String d = r.getText(); // get text that contains \r\n (in CDATA)
} catch(...) {
}
----
getText() returns the proper data -- but the \r\n sequences have been converted to \n.
Is there any way to prevent this? I.e., I like to retrieve exactly what's in the file.
Thanks in advance.