Browse Source

Tree tabulado sin color

master
Ivan Morell 2 years ago
parent
commit
399d956865
2 changed files with 48 additions and 10 deletions
  1. BIN
      bin/Package/Tree.class
  2. +48
    -10
      src/Package/Tree.java

BIN
bin/Package/Tree.class View File


+ 48
- 10
src/Package/Tree.java View File

@ -4,16 +4,54 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class Tree { public class Tree {
public static void printFile(File f, String spaces) {
System.out.println(spaces.concat(File.separator).concat(f.getName()));
public static void main(String args[]) {
String ruta=".";
if (args.length>=1) {
ruta = args[0];
}
File file = new File(ruta);
treeRecursividad(file," ");
}
//private static void treeRecursividad(File f, String spaces) {
/*if(!file.exists())
return;
for(File f : file.listFiles()) {
System.out.println(f.getName());
if(f.isDirectory())
treeRecursividad(f);
}*/
public static void treeRecursividad(File f, String spaces) {
System.out.println(spaces.concat(File.separator).concat(f.getName()));
if (f.isDirectory() && f.canRead()) {
for (File file : f.listFiles()) {
treeRecursividad(file, spaces.concat(" "));
}
}
}
/*public static void printFile(File f, String spaces) {
System.out.println(ANSI_YELLOW+spaces.concat(File.separator).concat(f.getName())+ANSI_RESET);
if (f.isDirectory() && f.canRead()) { if (f.isDirectory() && f.canRead()) {
for (File file : f.listFiles()) { for (File file : f.listFiles()) {
String ext = f.getName(); 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);
}*/
if(ext.toLowerCase().contains("t")) {
System.out.println(spaces.concat(File.separator).concat(f.getName()));
}
printFile(file, spaces.concat(" ")); printFile(file, spaces.concat(" "));
} }
} }
@ -21,13 +59,13 @@ public class Tree {
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String ruta = "Documentos";
String ruta = "C:\\Users\\Ivan\\Desktop\\Nueva carpeta";
if(args.length==1) { if(args.length==1) {
printFile(new File(args[0]),""); printFile(new File(args[0]),"");
} else } else
printFile(new File("."), "");
printFile(new File(ruta), "");
} }
*/
public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_GREEN = "\u001B[32m";


Loading…
Cancel
Save