exception handling, creating log and continue the program in JAVA

前端 未结 3 1217
暖寄归人
暖寄归人 2021-01-28 13:04

I am designing a program in JAVA that captures results in about 10 iterations. At the end of these iterations all the results must be written into a log file.

If any ex

3条回答
  •  深忆病人
    2021-01-28 13:26

    OutputStream os = ....;
    PrintStream  ps = new PrintStream(os);
    
    while(notDone) {
        try {
            doStuff();
        }
        catch(Throwable t) {
            t.printStackTrace(ps);
        }
        ps.print(results);
    }
    

提交回复
热议问题