File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes OutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "OutputStream" Watch "OutputStream" New topic
Author

OutputStream

Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Hi,
I am using a method that writes it's contents to an output stream.
How can I instead capture those contents into a java String?



Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24056
    
  13

You can use a ByteArrayOutputStream to collect the data, then use toByteArray() to get the bytes, and then construct a String from them.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutputStream
 
Similar Threads
reading the content in outputstream
BLOB(image) -> ByteArrayOutputStream -> display on screen
excel file generation in weblogic portal
How to transform a OutputStream in a InputStream?
OutputStream contents