Community
Participate
Working Groups
Build ID: M20070921-1145 Steps To Reproduce: Use CommandLauncher and ConsoleOutputStream to read textual input from a tool that is producing something other than ASCII/Latin-1. More information: I'm assuming CommandLauncher and ConsoleOutputStream are intended as API, even though I've found no documentation. They are certainly handy for calling an external tool; takes a lot of tedium out of the work. However, the combination rather oddly goes from bytes to chars (in InputStreamReader) to bytes (in ProcessClosure) to chars (in ConsoleOutputStream). And in the final step, ConsoleOutputStream is not designed to handle anything other than ASCII. Either ConsoleOutputStream should be improved have a more intelligent byte->char conversion, or a new API using chars should be given. Such as: CommandLauncher.waitAndRead(Writer out, Writer err); this can then be used with CharArrayWriter to achieve the same functionality. As far as I can see ConsoleOutputStream as it stands could be reduced in its entirety to: public class ConsoleOutputStream extends ByteArrayOutputStream { public synchronized String readBuffer() { return toString(); } } which should then give appropriate encoding behaviour.
Oops, that suggested implementation should be: public class ConsoleOutputStream extends ByteArrayOutputStream { public synchronized String readBuffer() { String result = toString(); reset(); return result; } }