Here is my code with some comments attached.
i just explicitly thrown an exception and wanted to check the exception result in my output file .nevertheless ,there was nothing related to exception messages
but the source code lines.
Thanks in advance!
Ulf Dittmer wrote:What did you expect the file to contain? At a quick glance, the code produces no output except what the user types in. The IOException is ignored - did you mean to add a catch block that cause something to be written to Stdout or Stderr?
well,actually, in my mind ,the statement will write exception infos to the stderr which is redirectied to a file called
exception.txt hard-coded in my program, plus, i did not want to add a catch a block and write the exception messages on my own!
Thanks. Do you have any idea why this ?
Ulf Dittmer wrote:
in my mind ,the statement throw new IOException(); will write exception infos to the stderr which is redirectied to a file called exception.txt hard-coded in my program
It does not. By having a try/finally, the code is catching the exception, but not doing anything with it.
Gotcha, i probably should write the statement within my catch block . Many thanks!