private static void translateSeparator ( final String path , final int startIdx , final int endIdx , final boolean stripFinalSeparator , final StringBuilder buf ) { for ( int i = startIdx ; i < endIdx ; i ++ ) { final char c = path . charAt ( i ) ; if ( c == ' ' || c == ' ' ) { // Strip trailing separator, if necessary if ( i < endIdx - 1 || ! stripFinalSeparator ) { // Remove duplicate separators final char prevChar = buf . length ( ) == 0 ? ' ' : buf . charAt ( buf . length ( ) - 1 ) ; if ( prevChar != ' ' ) { buf . append ( ' ' ) ; } } } else { buf . append ( c ) ; } } }
Translate backslashes to forward slashes optionally removing trailing separator .