I have the following program:
public static void veureinfo(String filePath) throws FileNotFoundException{
File origen = new File(filePath);
if (origen.isFile()){
System.out.println("Java VeureInfo " +origen.getAbsolutePath());
System.out.println("INFORMACIÓ: Informació sobre el fitxer:");
System.out.println("Nom del fitxer : "+origen.getName());
System.out.println("Ruta : "+origen.getPath());
System.out.println("Ruta Absoluta : "+origen.getAbsolutePath());
System.out.println("Es pot escriure : "+origen.canWrite());
System.out.println("Es pot lleguir : "+origen.canRead());
System.out.println("Grandaria : "+origen.length()+(" bytes"));
}else{
System.out.println("directorio") ;
}
}
public static void main(String args[]) {
try {
veureinfo(args[0]);
} catch (FileNotFoundException error) {
System.out.println(error);
}
}
}
The doubt that I have is, if I leave empty the space of the arguments is to say if I do not put any error skips me:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at veureinfo.VeureInfo.main (VeureInfo.java:35) C: \ Users \ Montse \ AppData \ Local \ NetBeans \ Cache \ 8.1 \ executor-snippets \ run.xml: 53: Java returned: 1 BUILD FAILED (total time: 0 seconds)
How can I capture this error?