From abe87f88e6e891dbaeb895d7d51cb63862289c52 Mon Sep 17 00:00:00 2001 From: vigliom Date: Wed, 28 Sep 2022 20:47:54 +0200 Subject: [PATCH] Soluciono problema --- bin/jorpelu/com/Tree.class | Bin 1569 -> 1267 bytes src/jorpelu/com/Tree.java | 44 +++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/bin/jorpelu/com/Tree.class b/bin/jorpelu/com/Tree.class index 1fd8821637da61dde851522e2b21d62065c25356..4748537a04286182d5fc569c6a99b1564eb546ec 100644 GIT binary patch literal 1267 zcmZuw%Tg0j5Ir}qN#gKI07V566vIQJsGtP#!9!495~K=UP?zC?qsdHaGFV#W(w}hY z%C#)O(kef|o!{Vpi02OBrP)m1>F(R7`}Da#|9txa;4YR8gaqnexn4;Xwz8I6%r1FK z8Hi}Fd?T|3>1<}_*Ip^h7l@76j_r>MgfrdC0+BIyT_q7l!bB7?fw~#nQFB|xHRUbI zwSp2z&A65>|fj*YZj&L2sCG2%pBq8eb06_a~d-_@zzo$-*%m{ zfs{Zx$geUWdoN^u$zBZ_EphD7p{<5cZ)3M~H1|GYfac-KaP-GuBs}^Vtu4{kfmz;4P3~Z-uQ&CCci6;- zuxM?HeA@f1y9o#5wFOAEXyhmz9AOYCjB=q&j#i)M(aRon?gD)w iW`Zv%yoc+E8AuycyATEw(XvO1Llqx*X^E*JJo^iS?F&!< literal 1569 zcmZux-*XdH6#j0q$=#GKZMRKp6(k^HlF~+t7Hwz|sHm8xXiBwI#cg^ii%B+aHVBW- z_{KjVzA@uW#y9mLb!4UwK04#0qyL5f0Au}bvV^wu<(xhD{QAy!&)q-%`)wP*9Lf?A zfx+9JUssi8uIyEF%f3<)hCX%fIJt^b+srMk-&W;7Ab!rRxxu_ZG@V%yFfMr;st-{l zEW{8O7$~?kRcuz*mA~w)SCoKV@XAhQ#qnKjhlfUR%WY`i{=RwEtU7K@U^Kl}c-p@d z_-<`8pII?6Bp{|Fh6SvS-}Q2r-3n3INNNIEECXye5ZFcB``CRiX)qNjcTL#0i11{ZKD9-O7gYO`H@+6ulJt z1uE5t<49`piiI>X#NpKIse-E+6CXjv}R1!^+c7L=IC_`Z*(|v8(m`0;w_0c_p;Nu4-2#4jmbMsrKy%~3Y^+K zMR#ZN2S740CvZ5W8mVS2b<-{1Qod*6yueU+w&D6*H_vxH4d{Y}i?~D{E4(ueiT5^? z&V>6B-aqHG@s5Sd8u}r(u@IKHXW~6>OwPm=sv9N>ROd|;snRB{3Pduz7aJd0C}}?B zrV5Hqm8)ww{w7-uAFzmY`pv-UtZ?s$Y#*mWN^vgCrlRq!k`WOV-FUx+r~r4Y;?Nt2=?m47Dg6N zw=woTj{Jfb9^v?^{n8d*o@nD#8`(CdTKIwfGY@bq^iTYX8AjOWc7=Si&o|%mG577_ z*UUGfQ(iPj1N@mT`?bioclsFc2Dd12>u>L=myjDE` diff --git a/src/jorpelu/com/Tree.java b/src/jorpelu/com/Tree.java index 1f9553c..6a6b367 100644 --- a/src/jorpelu/com/Tree.java +++ b/src/jorpelu/com/Tree.java @@ -1,31 +1,27 @@ package jorpelu.com; - import java.io.File; +import java.io.IOException; public class Tree { - - public static void main(String[] args) { - String ruta="."; - if (args.length>=1) ruta = args[0]; - File fich = new File(ruta); - if(!fich.exists()) { - System.out.println("No exite "+ruta); - } else { - if(fich.isFile()) { - System.out.println(ruta+" es un fichero"); - } else { - System.out.println(ruta+" es un directorio"); - File[] ficheros=fich.listFiles(); - for (File f:ficheros) { - String textoDescr = f.isDirectory() ? "/" : - f.isFile() ? "_" : "?"; - System.out.println("("+textoDescr+") "+f.getName()); - - } - } - } - - } + + public static void main(String[] args) throws IOException { + printFile(new File("."), ""); + } + + 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()) { + System.out.print("|"); + printFile(file, spaces.concat("__")); + } + } + + } + + }