public static string Getalldirectorisandfiles (string path) {map<string, object> responsemap = new Hashmap<st Ring, object> (); Responsemap.put ("Time_stamp", Tools.currenttime ()); String responsestring = "", try {getdirectorisandfiles (path, Responsemap, "data"), responsestring = (new Gson ()). ToJson ( RESPONSEMAP);} catch (Exception e) {System.out.println ("files list read exception");} return responsestring; public static void Getdirectorisandfiles (string path, map<string, object> resultmap, String directoryname) {System.out.println (path); System.out.println (directoryname); File File = new file (path); arraylist<object> DataArray = new arraylist<object> (); File [] files = File.listfiles (); for (File a:files) {if (A.isdirectory ()) {map<string, object> tempmap = new Hashmap<string, object> (); Getdirectorisandfiles (path + a.getname () + "/", Tempmap, A.getname ()); Dataarray.add (TEMPMAP); }else{Dataarray.add (A.getname ()); }} resultmap.put (DirectoryName, DataArray);}
Recursively read the implementation of all folders and files in the development directory (Java)