• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic