Recursively read the implementation of all folders and files in the development directory (Java)

Source: Internet
Author: User

  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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.