question: public static String trim ( String s , boolean leading , boolean trailing , String sp ) { char space = ( sp == null || sp . length ( ) < 1 ) ? ' ' : sp . charAt ( 0 ) ; if ( leading ) { int len = s . length ( ) , i = 0 ; while ( i < len && s . charAt ( i ) == space ) { i ++ ; } s = ( i == 0 ) ? s : s . substring ( i ) ; } if ( trailing ) { int endIndex = s . length ( ) - 1 ; int i = endIndex ; while ( i >= 0 && s . charAt ( i ) == space ) { i -- ; } s = i == endIndex ? s : s . substring ( 0 , i + 1 ) ; } return s ; }
target:  Trim a character from a string.