I have the following program:
- If it's a file, I want you to show me (route, name, size)
- if it's not a file show me then it's a directory.
the data takes it out of parameter.
The code:
public class VeureInfo {
public static void VeureInfo(String filePath) throws FileNotFoundException, IOException {
File origen = new File(filePath);
Scanner reader = new Scanner(origen);
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") ;
}
}
} catch (Exception e) {
System.out.println("No hi han fitxers visibles que cumpleixin amb el patró :"+filePath);
}
}
public static void main(String args[]) throws IOException{
VeureInfo.VeureInfo(args[0]);
}
}
I have a problem
Does my program read both things well, namely files and directories? I put a directory parameter and I miss error .. :( that is, it tells me that it does not find anything by the name of the directory .. What's wrong?
Thank you,