public static String pathElement ( final int index , final String path ) { final String [ ] paths = path . split ( "/" ) ; int idx = index ; if ( ( paths [ 0 ] == null ) || ( paths [ 0 ] . length ( ) == 0 ) ) { // skip empty first part - leading "/" idx ++ ; } if ( idx >= paths . length ) { return null ; } return paths [ idx ] ; }
get the nth element from the path - first is 0 .