|
|
@ -1,17 +1,36 @@ |
|
|
|
package jorpelu.com; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.File; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class Tree { |
|
|
|
static int contador = 0; |
|
|
|
static String colores[] = new String[7]; |
|
|
|
|
|
|
|
public static final String ANSI_GREEN = "\u001B[32m"; |
|
|
|
|
|
|
|
public static final String ANSI_RESET = "\u001B[0m"; /* |
|
|
|
* public static final String ANSI_BLACK = "\u001B[30m"; public static final |
|
|
|
* String ANSI_RED = "\u001B[31m"; |
|
|
|
* |
|
|
|
* public static final String ANSI_YELLOW = "\u001B[33m"; public static final |
|
|
|
* String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = |
|
|
|
* "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; |
|
|
|
*/ |
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
colores[0] = "\u001B[30m"; |
|
|
|
colores[1] = "\u001B[31m"; |
|
|
|
colores[2] = "\u001B[32m"; |
|
|
|
colores[3] = "\u001B[33m"; |
|
|
|
colores[4] = "\u001B[34m"; |
|
|
|
colores[5] = "\u001B[35m"; |
|
|
|
colores[6] = "\u001B[36m"; |
|
|
|
printFile(pideRuta(), ""); |
|
|
|
} |
|
|
|
|
|
|
|
public static File pideRuta() { |
|
|
|
System.out.println("Introduzca una ruta a analizar: "); |
|
|
|
System.out.println(ANSI_GREEN.concat("Introduzca una ruta a analizar: "+ANSI_RESET)); |
|
|
|
Scanner sc = new Scanner(System.in); |
|
|
|
File f = null; |
|
|
|
try { |
|
|
@ -25,13 +44,22 @@ public class Tree { |
|
|
|
} |
|
|
|
|
|
|
|
public static void printFile(File f, String spaces) { |
|
|
|
System.out.println(spaces.concat("|____").concat(f.getName())); |
|
|
|
|
|
|
|
System.out.println(spaces.concat("|____").concat(f.getName())+ANSI_RESET); |
|
|
|
if (f.isDirectory() && f.canRead()) { |
|
|
|
for (File file : f.listFiles()) { |
|
|
|
|
|
|
|
printFile(file, spaces.concat(" ")); |
|
|
|
printFile(file, spaces.concat(" " + colores[contador])); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(contador<6) { |
|
|
|
contador++; |
|
|
|
}else{ |
|
|
|
contador = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |