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

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -