Java, Catching an exception and passing it to a method -


i created method accepts ioexception argument. method opens out stream , prints information exception text file. problem seem running into.. how call method catch block?

try{     if(true)         throw new ioexception(); } catch(ioexception e){     //pass method } 

:::edit:::

public void logerrors(ioexception e){     printwriter out = yada yada;      out.println(e.getcause()); } 

basically have call name of method, want method's code executed this:

try{     if(true)         throw new ioexception(); } catch(ioexception e){     //pass method     methodtoexecute(e); }  also, can see throw ioexception in both cases perhaps  may want consider modifying code use block 

edit

on second thought, can use if statement throw always.

if (...) {    yourmethod(throw new ioexception()); } 

Comments

Popular posts from this blog

renaming files in a directory using python or R -

html - outline-style different in chrome compared to firefox and internet explorer -

vbscript - How to batch combine PDFs with sub-folder based non-JavaScript bookmarks -