public void recurseMakeDirectory ( String path ) throws SftpStatusException , SshException { SftpFile file ; if ( path . trim ( ) . length ( ) > 0 ) { try { file = openDirectory ( path ) ; file . close ( ) ; } catch ( SshException ioe ) { int idx = 0 ; do { idx = path . indexOf ( ' ' , idx ) ; String tmp = ( idx > - 1 ? path . substring ( 0 , idx + 1 ) : path ) ; try { file = openDirectory ( tmp ) ; file . close ( ) ; } catch ( SshException ioe7 ) { makeDirectory ( tmp ) ; } } while ( idx > - 1 ) ; } } }
Recurse through a hierarchy of directories creating them as necessary .