public static String decode(String s, String enc)
            throws MalformedURLException, UnsupportedEncodingException {

        int length = s.length();
        byte[] bytes = new byte[length];
        int j = 0;

        for (int i = 0; i < length; i++) {
            if (s.charAt(i) == '%') {
                i++;  // skip %
                try {
                    bytes[j++] = (byte)
                            Integer.parseInt(s.substring(i, i + 2), 16);

                } catch (Exception e) {
                    throw IIOPLogger.ROOT_LOGGER.invalidURIEncoding(s);
                }
                i++;  // skip first hex char; for loop will skip second one
            } else {
                bytes[j++] = (byte) s.charAt(i);
            }
        }

        return new String(bytes, 0, j, enc);
    }
public static String decode(String s, String enc)
            throws MalformedURLException, UnsupportedEncodingException {

        int length = s.length();
        byte[] bytes = new byte[length];
        int j = 0;

        for (int i = 0; i < length; i++) {
            if (s.charAt(i) == '%') {
                i++;  
                try {
                    bytes[j++] = (byte)
                            Integer.parseInt(s.substring(i, i + 2), 16);

                } catch (Exception e) {
                    throw IIOPLogger.ROOT_LOGGER.invalidURIEncoding(s);
                }
                i++;  
            } else {
                bytes[j++] = (byte) s.charAt(i);
            }
        }

        return new String(bytes, 0, j, enc);
    }
public static String decode ( String s , String enc ) throws MalformedURLException , UnsupportedEncodingException { int length = s . length ( ) ; byte [ ] bytes = new byte [ length ] ; int j = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( s . charAt ( i ) == ' ' ) { i ++ ; // skip % try { bytes [ j ++ ] = ( byte ) Integer . parseInt ( s . substring ( i , i + 2 ) , 16 ) ; } catch ( Exception e ) { throw IIOPLogger . ROOT_LOGGER . invalidURIEncoding ( s ) ; } i ++ ; // skip first hex char; for loop will skip second one } else { bytes [ j ++ ] = ( byte ) s . charAt ( i ) ; } } return new String ( bytes , 0 , j , enc ) ; }
Decode a URI string (according to RFC 2396).
<p/>
Three-character sequences '%xy', where 'xy' is the two-digit
hexadecimal representation of the lower 8-bits of a character,
are decoded into the character itself.
<p/>
The string is subsequently converted using the specified encoding
Decode a URI string ( according to RFC 2396 ) . <p / > Three - character sequences %xy where xy is the two - digit hexadecimal representation of the lower 8 - bits of a character are decoded into the character itself . <p / > The string is subsequently converted using the specified encoding