question: public static String urlEncode ( String s , boolean doNotEncodeSlashOrColon ) { try { String result = s ; if ( doNotEncodeSlashOrColon ) { result = result . replace ( "/" , "HERELIESASLASH_ICIUNSLASH" ) ; result = result . replace ( ":" , "HERELIESACOLON_ICIUNSLASH" ) ; } result = URLEncoder . encode ( result , "utf-8" ) ; result = result . replace ( "+" , "%20" ) ; if ( doNotEncodeSlashOrColon ) { result = result . replace ( "HERELIESASLASH_ICIUNSLASH" , "/" ) ; result = result . replace ( "HERELIESACOLON_ICIUNSLASH" , ":" ) ; } return result ; } catch ( UnsupportedEncodingException e ) { return null ; } }
target:  URL encode a string with control over how special characters are handled