[jdom-interest] Re: Thread questions regarding JDOM SAXBuiler?

David Wall d.wall at computer.org
Sun Aug 29 15:43:10 PDT 2004

The SAXBuilder.build() javadocs say this about using a StringReader (Reader
actually):  "It's always safer to use an InputStream rather than a Reader,
if it's available."

But if I already have the XML in a String, I could use
java.io.StringBufferInputStream, though that's been deprecated for
StringReader because:  "Deprecated. This class does not properly convert
characters into bytes. As of JDK 1.1, the preferred way to create a stream
from a string is via the StringReader class.  ...    Only the low eight bits
of each character in the string are used by this class.".

So the question is, why is it "safer" to use an InputStream since the
StringBufferInputStream is deprecated?  Would you recommend using a
StringReader or converting the String to a byte array and then using
ByteArrayInputStream for the SAXBuilder.build()?  Or something else


More information about the jdom-interest mailing list