Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Redirect OutputStream to a String / StringWriter  RSS feed

 
Saurabh Deshpande
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am having a channel i am communicating remotely to execute Unix commands.
I would like to know how do i give an OutputStream reference to that actually rights to a StringWriter.

Currently using channel.setOutputStream(System.out);
This displays the output on console, but i want to write it to a String / StringBuffer / StringWriter.

Let me know if you have any ideas.
Cheers,
Saurabh
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to see which channel api provides setOutputStream() method. I could not find one (i could have missed)
Anyways, you can use a ByteArrayOutputStream. It provides a toString() method which also takes encoding.
 
abhishek jethwani
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which channel you are using. because as far as i know no channel provide setOutputStream method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!