  |
L'esempio completo: |
public class Eccezioni {
public static
void main(String [] args) {
InputStream in=null;
OutputStream out=null;
try {
int c;
in = new FileInputStream(args[0]);
out = new FileOutputStream(args[1];)
while( (c=in.read()) != -1)
out.write (c);
} catch(
ArrayIndexOutOfBoundsException ex) {
System.out.println(
"not enough args");
} catch(
FileNotFoundException ex) {
System.out.println(
"file not found");
} catch (
IOException ex) {
System.out.println(
"I/O error");
} finally{
try { in.close(); }
catch(Exception ex) { }
try { out.close(); }
catch(Exception ex) { }
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
|