|
|
@ -0,0 +1,31 @@ |
|
|
|
package es.antoniotgit; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
public class TreeComand { |
|
|
|
public static void printFile(File f, String spaces, String extension) { |
|
|
|
System.out.println(spaces.concat(/*File.separator*/"").concat(f.getName())); |
|
|
|
if (f.isDirectory() && f.canRead()) { |
|
|
|
for (File file : f.listFiles()) { |
|
|
|
if(file.isDirectory() || file.getName().endsWith(extension)) |
|
|
|
printFile(file, spaces.concat("_"),extension); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException{ |
|
|
|
if(args.length > 2) { |
|
|
|
System.out.println("ERROR solo 2 argumentos"); |
|
|
|
System.exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
String path = args[0]; |
|
|
|
String extension = args[1]; |
|
|
|
|
|
|
|
printFile(new File(path), "|", extension); |
|
|
|
//"C:\\Users\\Anto.LAPTOP-CR44LNOV\\Desktop\\PMDM" |
|
|
|
} |
|
|
|
|
|
|
|
} |