Wednesday 8 November 2017

java - Output stream over a StringBuilder

I think this has been answered but I can't seem to find
it.


I have an instance method which writes some contents to
an output
stream


writeTo(OutputStream){

//class specific
logic
}

I want it to
get these contents into a StringBuilder. I can do this via a temporary file but that
does not seem right. I want to do something
like:


Stringbuilder sb = /*
*/;
OutputStream os = outForStringBuilder(sb);//not sure how to do
this
instance.writeTo(os); //This should write the contents to
Stringbuilder

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...