In merito a quanto gia' discusso in un altro post
se io ho questa funzione:
Non faccio alcun controllo in merito al parametro del metodo.codice:void scrivi( String path ) throws IOException { Iterator it = lineOfFile.entrySet().iterator(); FileOutputStream fos = null; PrintStream ps = null; try { fos = new FileOutputStream(filename); ps = new PrintStream(fos); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); ps.println(entry.getKey() + " " + entry.getValue()); } } finally { if (ps != null) { ps.close(); } else if (fos != null) { fos.close(); } } }
Per controllare se la stringa path e' null metto un if-end if all'interno del metodo oppure devo fare che lanci una eccezione. Nel secondo caso come faccio a dire a Java che catturi piu' eccezioni.
Grazie