|
@ -0,0 +1,40 @@ |
|
|
|
|
|
package Package; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
public class Tree { |
|
|
|
|
|
public static void printFile(File f, String spaces) { |
|
|
|
|
|
System.out.println(spaces.concat(File.separator).concat(f.getName())); |
|
|
|
|
|
if (f.isDirectory() && f.canRead()) { |
|
|
|
|
|
for (File file : f.listFiles()) { |
|
|
|
|
|
String ext = f.getName(); |
|
|
|
|
|
String [] partes = ext.split("."); |
|
|
|
|
|
System.out.print(partes[0]); |
|
|
|
|
|
/*if(partes[1].equals("txt")) { |
|
|
|
|
|
System.out.printf(ANSI_YELLOW+spaces.concat(File.separator).concat(f.getName())+ANSI_RESET); |
|
|
|
|
|
}*/ |
|
|
|
|
|
printFile(file, spaces.concat(" ")); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
|
|
String ruta = "Documentos"; |
|
|
|
|
|
if(args.length==1) { |
|
|
|
|
|
printFile(new File(args[0]),""); |
|
|
|
|
|
} else |
|
|
|
|
|
printFile(new File("."), ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static final String ANSI_BLACK = "\u001B[30m"; |
|
|
|
|
|
public static final String ANSI_RED = "\u001B[31m"; |
|
|
|
|
|
public static final String ANSI_GREEN = "\u001B[32m"; |
|
|
|
|
|
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 final String ANSI_WHITE = "\u001B[37m"; |
|
|
|
|
|
public static final String ANSI_RESET = "\u001B[0m"; |
|
|
|
|
|
} |