java - Recursively create directory -


does know how use java create sub-directories based on alphabets (a-z) n levels deep?

 /a     /a         /a         /b         /c         ..     /b         /a         /b         ..     ..         /a         /b         /c         ..  /b     /a         /a         /b         ..     /b         /a         /b         ..     ..         /a         /b         .. ..     /a         /a         /b         ..     /b         /a         /b         ..     ..         /a         /b         .. 

public static void main(string[] args) {   file root = new file("c:\\so");   list<string> alphabet = new arraylist<string>();   (int = 0; < 26; i++) {     alphabet.add(string.valueof((char)('a' + i)));   }    final int depth = 3;   mkdirs(root, alphabet, depth); }  public static void mkdirs(file root, list<string> dirs, int depth) {   if (depth == 0) return;   (string s : dirs) {     file subdir = new file(root, s);     subdir.mkdir();     mkdirs(subdir, dirs, depth - 1);   } } 

mkdirs recusively creates depth-level directory tree based on given list of strings, which, in case of main, consists of list of characters in english alphabet.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -