commit 2df7d8b840c34382f5b0813c5fff86269651a1ae Author: Dani Minguet Date: Mon Sep 26 19:06:44 2022 +0200 Arbol diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..659d77f --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Arbol + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e8b2323 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +MUESTRA TODOS LOS DIRECTORIOS, SUBDIRECTORIOS Y ARCHIVOS QUE SE ENCUENTRE EN LA RUTA INDICADA POR PARÁMETRO + +Se ha elaborado con un bucle que se llama a él mismo las veces que sea necesaria para poder mostrar los elementos de la +ruta que esté indicada en el momento, y se muestran con la ayuda del comando ".concat()" y poniendo tabulaciones +para poder representarlo más claramente + +RESULTADO: + +``` +NIVELES DE RECURSIVIDAD SEGÚN DIRECTORIO O SUBDIRECTORIO: + +NIVEL 1 NIVEL 2 NIVEL 3 NIVEL 4 NIVELES INFERIORES---> +Documents + Mi música + Mis imágenes + Mis vídeos + Programación + .idea + .gitignore + misc.xml + modules.xml + runConfigurations.xml + workspace.xml + Programación.iml + Tema6 + Ej11.java + workspace-spring-tool-suite-4-4.15.3.RELEASE +``` \ No newline at end of file diff --git a/bin/arbol/com/daniminguet/es/Arbol.class b/bin/arbol/com/daniminguet/es/Arbol.class new file mode 100644 index 0000000..00b88bd Binary files /dev/null and b/bin/arbol/com/daniminguet/es/Arbol.class differ diff --git a/bin/module-info.class b/bin/module-info.class new file mode 100644 index 0000000..015be7c Binary files /dev/null and b/bin/module-info.class differ diff --git a/src/arbol/com/daniminguet/es/Arbol.java b/src/arbol/com/daniminguet/es/Arbol.java new file mode 100644 index 0000000..163479c --- /dev/null +++ b/src/arbol/com/daniminguet/es/Arbol.java @@ -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) { + } + } +} diff --git a/src/module-info.java b/src/module-info.java new file mode 100644 index 0000000..f4708be --- /dev/null +++ b/src/module-info.java @@ -0,0 +1,3 @@ +module Arbol { + exports arbol.com.daniminguet.es; +} \ No newline at end of file