[jdom-interest] Getting String from a Document
Jason Hunter
jhunter at acm.org
Thu Jun 15 10:07:28 PDT 2000
> On the flip side, is there an easy way
> to turn a string into a document? We're using a
> ByteArrayInputStream now, but that seems a bit
> klunky and kludgy to me.
Use a StringBufferInputStream. That's not too klunky. Right now
SAXBuilder.build(String) assumes the string is a systemID so it wouldn't
be very easy to have a build that took a string representing a
document. I think using SBIS is fine.
> Also, why assume that
> all input sources of XML data are going to be
> 8-bit input streams? What if the input source
> is a serialized string? That's 16-bit unicode.
I doubt Java serializes strings using UCS-2. I suspect it's more likely
UTF-8. But regardless, you wouldn't want a build() that takes as input
a reference to a serialized string (which would of course be an
InputStream).
> The Stream verses Reader goes all the way
> back to the Xerces and DOM tho....
Well, we have a SAXBuilder.build(Reader) method.
-jh-
More information about the jdom-interest
mailing list