Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

obtaining InputStream/Reader from OutputStream/Writer to read the content

 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I want to get the input stream/reader from an outputstream/writer.
I am using XSLT transformer to generate HTML from XML using a XSLT.
hereis the code:

How do I get th oputput of the transform method in a String? I am passing a StreamResult object which wraps a OutputStream. The StreamResult object also can wrap a Writer. Now how do I obtain the content of the OutputStream or Writer? I think i will need to use a InputStream or a Reader from which i can obtain the data as String by using read(..) method. Am i right? If that is so, how do I obtain the InputStream or a Reader from the OutputStream or Writer?
many thanks in advance
Tanveer
[ June 30, 2005: Message edited by: Tanveer Rameez ]
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tanveer,

you can use a ByteArrayOutputStream as the wrapped OutputStream, and afterwards, call toString on the baos.

Hope it helps
Detlev
[ June 29, 2005: Message edited by: Detlev Beutner ]
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Thanks for the reply. Yes, that is a good away. I found another way of doing it too:


The StringWriter is a Writer and getbuffer gives the data written to that writer.

cheers
Tanveer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic