public static String addTrailingSlashIfNeeded ( String directory ) { if ( StringUtils . isNullOrBlank ( directory ) ) { return StringUtils . EMPTY ; } int separator = indexOfLastSeparator ( directory ) ; String slash = SystemInfo . isUnix ( ) ? Character . toString ( UNIX_SEPARATOR ) : Character . toString ( WINDOWS_SEPARATOR ) ; if ( separator != - 1 ) { slash = Character . toString ( directory . charAt ( separator ) ) ; } return directory . endsWith ( slash ) ? directory : directory + slash ; }
Adds a trailing slash if its needed . Tries to determine the slash style but defaults to unix . Assumes that what is passed in is a directory .