vigliom 2 years ago
parent
commit
9cf1686743
2 changed files with 18 additions and 26 deletions
  1. BIN
      bin/jorpelu/com/Tree.class
  2. +18
    -26
      src/jorpelu/com/Tree.java

BIN
bin/jorpelu/com/Tree.class View File


+ 18
- 26
src/jorpelu/com/Tree.java View File

@ -5,32 +5,19 @@ 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_YELLOW = "\u001B[33m";
public static final String ANSI_PURPLE = "\u001B[35m";
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(ANSI_GREEN.concat("Introduzca una ruta a analizar: "+ANSI_RESET));
System.out.println(ANSI_GREEN.concat("Introduzca una ruta a analizar: " + ANSI_RESET));
Scanner sc = new Scanner(System.in);
File f = null;
try {
@ -44,12 +31,19 @@ public class Tree {
}
public static void printFile(File f, String spaces) {
if(f.isDirectory())
System.out.println(colores[5]);
else if(f.isFile())
System.out.println(colores[2]);
System.out.println(spaces.concat("|____").concat(f.getName())+ANSI_RESET);
if (f.isDirectory()) {
System.out.print(ANSI_GREEN);
}else if(f.isDirectory() && f.isHidden()) {
System.out.print(ANSI_YELLOW);
}else if (f.isFile()) {
System.out.print(ANSI_PURPLE);
} else if (f.isFile() && f.isHidden()){
System.out.print(ANSI_YELLOW);
}
System.out.println(spaces.concat("|____").concat(f.getName()) + ANSI_RESET);
System.out.println(ANSI_RESET);
if (f.isDirectory() && f.canRead()) {
for (File file : f.listFiles()) {
@ -57,9 +51,7 @@ public class Tree {
printFile(file, spaces.concat(" "));
}
}
}
}

Loading…
Cancel
Save