Recursively create directory

前端 未结 10 642
萌比男神i
萌比男神i 2020-12-30 23:20

Does anyone know how to use Java to create sub-directories based on the alphabets (a-z) that is n levels deep?

 /a
    /a
        /a
        /b
        /c
           


        
10条回答
  •  执念已碎
    2020-12-30 23:48

    If you don't mind relying on a 3rd party API, the Apache Commons IO package does this directly for you. Take a look at FileUtils.ForceMkdir.

    The Apache license is commercial software development friendly, i.e. it doesn't require you to distribute your source code the way the GPL does. (Which may be a good or a bad thing, depending on your point of view).

提交回复
热议问题