Is there readily available functionality for Java to create a folder hierarchy on a remote FTP server. Apache Commons does provide an FTP client, but I can’t find a method for creating a directory hierarchy.
It does allow for creating a single directory (makeDirectory), but creating an entire path does not seem to be in there.
The reason I want this is because sometimes part of a directory hierarchy is not (yet) available and in such a case I want to create the missing part of the hierarchy and then change to that newly created directory.
Is there readily available functionality for Java to create a folder hierarchy on a
Share
You have to use a combination of
FTPClient.changeWorkingDirectoryto figure out if the directory exists, thenFTPClient.makeDirectoryif the call toFTPClient.changeWorkingDirectoryreturnsfalse.You need to recursively walk the directory tree in the manner described above at each level create the directory as required.