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

OutputStream

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a ByteArrayOutputStream to collect the data, then use toByteArray() to get the bytes, and then construct a String from them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic