java - Do action when something is printed in System.err -
like in topic - trying action when printed error stream, code below not working:
try { system.setout(new printstream("infolog.txt")); system.seterr(new printstream(new fileoutputstream("errorlog.txt") { public void write(int b) throws ioexception { super.write(b); error(); } public void write(byte[] b) throws ioexception { super.write(b); error(); } })); } catch (filenotfoundexception ex) { logger.getlogger(housecalc.class.getname()).log(level.severe, null, ex); }
is there way "catch" system.err stream , make action before gets printed file?
make sure override the appropriate methods. have @ source of printstream
, because might calling each other. want way down.
write(char cbuf[], int off, int len)
might 1 need.
Comments
Post a Comment