xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: InputStream from an SVGDocument?
Date Mon, 14 Nov 2005 19:15:33 GMT
Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Michael.Bishop@je.jfcom.mil> wrote on 
11/14/2005 02:04:06 PM:

>      I’m trying to implement/borrow the “View Source” functionality from 
the 
> Squiggle application, but I’ve hit a small roadblock.  The Squiggle 
> application needs the document’s URL to load and display the data.  What 

> happens if I have an SVG file that hasn’t been saved yet?  Is there a 
way to 
> get an InputStream to it? 

   The DOM has no 'stream' representation handy so the best you can do
is serialize the DOM (dom.util.DOMUtilities) to a stream.  At this point
you have two main options, one serialize to a ByteArrayOutputStream and
then wrap the generated byte array with a ByteArrayInputStream (i.e.
write to a temp file in memory), or get fancy with Input/Output Stream
Pipes.  The tricky bit with pipes is that you have to ensure that the
reader and writer are in different threads (which could get complex,
or simple, given that the DOM can only be accessed safely in the 
UpdateManager Thread), I think java 5 has some interesting things along
these lines but I don't know any of the details.

> I could write a temp file, but that seems sloppy.

   The ByteArray stream is what most people seem to do...

Mime
View raw message