• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
What? What, what, what? What what tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic