Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-slide Wiki" for 
change notification.

The following page has been changed by DarrenHartford:
http://wiki.apache.org/jakarta-slide/CreateDirectoryTreeInJava

New page:
Purpose:

Solve the problem of heavily nested paths when using MKCOL to create a 
directory structure with WebDAV.

i.e.  store a file under /COMPANYA/2006/08/test.file  requires multiple MKCOL 
commands as Slide needs the parent tree to exist before creating children.

Below is a java method that takes a jakarta WebdavResource and the path (such 
as "/COMPANYA/2006/08/") and creates the entire tree structure.


        private static String mkallcol(WebdavResource wdr, String path) throws 
Exception{
                if (path != null){
                        if (path.length() > 1){
                                path.replace('\\','/');
                                
                                //Now, break up path
                                java.util.StringTokenizer t = new 
java.util.StringTokenizer(path,"/");
                                String strsub = "/";
                                int count = t.countTokens();
                                //check each token EXCEPT last token, last 
token is filename
                        while ((t.hasMoreTokens()) && (count > 1)){
                                        strsub = strsub +  t.nextToken() + "/";
                                                wdr.mkcolMethod(wdr.getPath() + 
strsub);
                                        count--;
                                }
                                return wdr.getPath() + strsub + t.nextToken();
                        }else{
                                return "";
                        }
                }else{
                        return "";
                }
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to