public static String getPathSeparator ( String separator , String ... path ) { Check . notNull ( separator ) ; Check . notNull ( path ) ; final StringBuilder fullPath = new StringBuilder ( path . length ) ; for ( int i = 0 ; i < path . length ; i ++ ) { if ( i == path . length - 1 ) { fullPath . append ( path [ i ] ) ; } else if ( path [ i ] != null && path [ i ] . length ( ) > 0 ) { fullPath . append ( path [ i ] ) ; if ( ! fullPath . substring ( fullPath . length ( ) - 1 , fullPath . length ( ) ) . equals ( separator ) ) { fullPath . append ( separator ) ; } } } return fullPath . toString ( ) ; }
Construct a usable path using a list of string automatically separated by the portable separator .