'How to list folders and files from different paths stored in a json file - Java
I want to list all the folders and files from different paths stored in a json file in order to delete them later with a filter. In the folowing code I list the folders using the FILE class and only one path.
public class Depurador {
public static void main(String[] args) {
File ruta = new File("C:\\Users\\erick\\Desktop\\prueba");
ImprimirFicheros1(ruta, 0);
}
public static void ImprimirFicheros1(File file, int nivelArbol){
for(int i = 0; i < nivelArbol; i++){
System.out.print("-");
}
System.out.println(file.getName());
if(file.isDirectory()){
File[] listaFicheros = file.listFiles();
for(File fichero : listaFicheros){
ImprimirFicheros1(fichero, nivelArbol + 2);
}
}
}
I would like to list all the folders and files from this json file and not only from one path.
{
"Directorios":[
{
"ruta": "C:\\Users\\erick\\Desktop\\prueba",
"periodo": 15,
"archivos":["yyyy-mm-dd_reportesdetalles_1.csv, yyyy-mm-dd_reportesdetalles_2.csv"]
},
{
"ruta": "C:\\Users\\erick\\Desktop\\test",
"periodo": 20,
"archivos":["yyyy-mm-dd_test_1.csv, yyyy-mm-dd_test_2.csv"]
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
