get an outputstream string
what's best proceed summons cost an java.io.outputstream twine java?
say i have method:
writetostream(object o, outputstream out)
which writes certain information vigilant given stream. however, i wish cost twine simply possible.
i'm deliberation minute category (untested):
class stringoutputstream extends outputstream {
stringbuilder mbuf;
open vacant write(int byte) throws ioexception {
mbuf.append((char) byte);
}
open twine getstring() {
relapse mbuf.tostring();
}
}
but there improved way? i wholly wish run test!
Comments
Post a Comment