From 426f4c4299bcd55908afff7af855d7ce2ed8ee1c Mon Sep 17 00:00:00 2001 From: vigliom Date: Thu, 29 Sep 2022 00:16:39 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1ado=20los=20colores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bin/jorpelu/com/Tree.class | Bin 1812 -> 2461 bytes src/jorpelu/com/Tree.java | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 94e88f5..403a3bb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ###### Jorge Pérez Ludeña Aplicación que imita el comando tree. Pide una ruta, la cual analiza - +Hago que pinte por colores las diferentes carpetas Asi sale la consola ~~~ diff --git a/bin/jorpelu/com/Tree.class b/bin/jorpelu/com/Tree.class index c2d538651a56de81d8a36ff077aa07eda8862ecb..c57a5b002c5448ac05c5c343773097f22e82aa23 100644 GIT binary patch literal 2461 zcmZuzYgg1(6y2Ez31dJEg7}~vMUVk>5R{_$s1Kx69+sgLq^*Wb#OO>i&19%rYiq0a z{eIeS?H9kcxE8qTsz0EAp#P?H-(&`6DC1h*n{)3uckg|7PWb!ZKc4|Oj$dSiB-CAV z+?<&yBn>Bz*UNH}!{e(f3ibv3yR!-s!So=fox!x1)BVBp5U0stdYIFL!L%j5(m-1ql$lkEl2b;;+u}(mb&!p{2cY_y2Fs z7hZSg^VK+k7iFBR)cj`NGqWmA;WTf_DbP6$s}(PZb9gJJo+XU467~+;p6jFww+uaA zu=Ti0$Z`I&^^A2(caO%!#mCTyb1H`Ll7uR{(9l`5t%%e2Xwh{=qUE6&UdD)w^JSu! zflx6D+Ee!VXLyAT8&#c>aY4cs|I!Mcl}V-y-L_3v@SjkT!lZIR?V?TJd)mX-!HX4bU50a0~c#Z_2L&Q~VyUg!Arxrr&k z;<}2Ac!i=y#>w-@P~ITKz!c?r(uvX)3AL+s@$JeWbBfY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v`X7Pi?&KW?fO=Bqvx zT63pSp)8OsR*V7GU~eOvO)s1XD_+gFRJ~~vdVF2db%r7Kb(B*Mh;hgH#Qz4r3S8Ot z=o;Na{4Z`I903TgL4#x5n{@-OJ^V`GIC^Pyf_v?%FLZOAC)!QoEz+q|Z*jWqD#E$5KydOWl5tios0mkNtnOfORHk zLdR!`VUP^YVUlR)xZWcmEvRO|z#(pKxZA-~!kVNG4!P7B3?sUa%jhP2gWV!Xp$zox QvlhrIJOdwjbPz%1e~a*qd;kCd diff --git a/src/jorpelu/com/Tree.java b/src/jorpelu/com/Tree.java index 2f5ca91..84f474e 100644 --- a/src/jorpelu/com/Tree.java +++ b/src/jorpelu/com/Tree.java @@ -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; + } + } + }