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

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?