|
|
@ -0,0 +1,37 @@ |
|
|
|
package arbol.com.daniminguet.es; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
public class Arbol { |
|
|
|
|
|
|
|
public static void main(String args[]) throws IOException { |
|
|
|
String rutaString = "C:\\Users\\Dani\\Documents"; |
|
|
|
|
|
|
|
if(args.length >= 1) { |
|
|
|
rutaString = args[0]; |
|
|
|
} |
|
|
|
|
|
|
|
File ruta = new File(rutaString); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("NIVELES DE RECURSIVIDAD SEGÚN DIRECTORIO O SUBDIRECTORIO:"); |
|
|
|
System.out.println(); |
|
|
|
System.out.println("NIVEL 1\t\t\tNIVEL 2\t\t\tNIVEL 3\t\t\tNIVEL 4\t\t\tNIVELES INFERIORES--->"); |
|
|
|
|
|
|
|
listarDirectoriosArchivos(ruta, ""); |
|
|
|
} |
|
|
|
|
|
|
|
public static void listarDirectoriosArchivos(File ruta, String espacio) { |
|
|
|
System.out.println(espacio.concat(ruta.getName())); |
|
|
|
|
|
|
|
try { |
|
|
|
if (ruta.isDirectory() && ruta.canRead()) { |
|
|
|
for (File file : ruta.listFiles()) { |
|
|
|
listarDirectoriosArchivos(file, espacio.concat("\t\t\t")); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (NullPointerException npe) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |