question: public static String trimLeadingAndTrailingSlashes ( final String in ) { if ( null == in ) return in ; String out = in ; if ( out . startsWith ( "/" ) ) { out = out . substring ( 1 ) ; } if ( out . endsWith ( "/" ) ) { out = out . substring ( 0 , out . length ( ) - 1 ) ; } return out ; }
target:  Utility method for trimming and leading and/or trailing slashes from  it's input.  May return the empty string.  May return null if and only  if the input is null.