public static String encodeUrlIso ( String stringToEncode ) { try { return URLEncoder . encode ( stringToEncode , "ISO-8859-1" ) ; } catch ( UnsupportedEncodingException e1 ) { throw new RuntimeException ( e1 ) ; } }
URL - encodes a given string using ISO - 8859 - 1 which may work better with web pages and umlauts compared to UTF - 8 . No UnsupportedEncodingException to handle as it is dealt with in this method .