• Post Reply Bookmark Topic Watch Topic
  • New Topic

StreamResult to a String?  RSS feed

 
Scott Simpson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to figure out how to make something go from a StreamResult into a String in this:


the StreamResult param of that would usually take a FileStream or something, but i need it in a String or StringBuffer format. Can anyone help me? THanks in advance
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

You could write a StringOutputStream that extends OutputStream, then pass that to the approriate constructor of StreamResult.

It should be fairly simple to implement with a StringBuffer at it's core.

In fact, a cursory glance at google came up with this implementation which you could draw inspiration from.

Hope this helps.

/edit

Ignore me, I'm being silly!

Just use StringWriter

e.g.


[ March 08, 2005: Message edited by: Horatio Westock ]
 
Scott Simpson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a bunch! that last bit is exactly what i needed. wasn't too familiar with the StreamResult stuff.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Simpson:
trying to like java
Do, or do not. There is no try.

Sorry, couldn't resist.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Harkness:
Do, or do not. There is no try.

Sorry, couldn't resist.


"Do and Undo. There is always try." - Ronald E. Jeffries

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!