URL decoding: UnsupportedEncodingException in Java

后端 未结 3 709
说谎
说谎 2020-12-08 18:43

What I understand from the documentation is that UnsupportedEncodingException can only be thrown if I specify a wrong encoding as the second parameter to URLDecoder.decode(S

3条回答
  •  渐次进展
    2020-12-08 18:54

    That's because of the odd choice to make UnsupportedEncodingException checked. No, it won't be thrown.

    I usually do as follows:

    } catch (UnsupportedEncodingException e) {
      throw new AssertionError("UTF-8 not supported");
    }
    

提交回复
热议问题