public static String cleanUpPathPrefix(String prefix){
  if (UtilValidate.isEmpty(prefix))   return "";
  StringBuilder cppBuff=new StringBuilder(prefix.replace('\\','/'));
  if (cppBuff.charAt(0) != '/') {
    cppBuff.insert(0,'/');
  }
  if (cppBuff.charAt(cppBuff.length() - 1) == '/') {
    cppBuff.deleteCharAt(cppBuff.length() - 1);
  }
  return cppBuff.toString();
}

public static String cleanUpPathPrefix ( String prefix ) { if ( UtilValidate . isEmpty ( prefix ) ) return "" ; StringBuilder cppBuff = new StringBuilder ( prefix . replace ( '\\' , '/' ) ) ; if ( cppBuff . charAt ( 0 ) != '/' ) { cppBuff . insert ( 0 , '/' ) ; } if ( cppBuff . charAt ( cppBuff . length ( ) - 1 ) == '/' ) { cppBuff . deleteCharAt ( cppBuff . length ( ) - 1 ) ; } return cppBuff . toString ( ) ; }
make sure the string starts with a forward slash but does not end with one ; converts back - slashes to forward - slashes ; if in string is null or empty , returns zero length string .
