diff --git a/bin/jorpelu/com/Tree.class b/bin/jorpelu/com/Tree.class index 4748537..c2d5386 100644 Binary files a/bin/jorpelu/com/Tree.class and b/bin/jorpelu/com/Tree.class differ diff --git a/src/jorpelu/com/Tree.java b/src/jorpelu/com/Tree.java index 6a6b367..2f5ca91 100644 --- a/src/jorpelu/com/Tree.java +++ b/src/jorpelu/com/Tree.java @@ -1,27 +1,37 @@ package jorpelu.com; + import java.io.File; import java.io.IOException; - +import java.util.Scanner; public class Tree { - + public static void main(String[] args) throws IOException { - printFile(new File("."), ""); - } - + printFile(pideRuta(), ""); + } + + public static File pideRuta() { + System.out.println("Introduzca una ruta a analizar: "); + Scanner sc = new Scanner(System.in); + File f = null; + try { + f = new File(sc.next()); + + } catch (Exception e) { + e.setStackTrace(e.getStackTrace()); + } + sc.close(); + return f; + } + 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("__")); - } - } - - } - - + System.out.println(spaces.concat("|____").concat(f.getName())); + if (f.isDirectory() && f.canRead()) { + for (File file : f.listFiles()) { + + printFile(file, spaces.concat(" ")); + } + } + } }