I’m writing a program that uses java.net.URLDecoder.decode(String value, String encoding). Apparently, this method might throw an UnsupportedEncodingException, which I get. But I’m just passing “UTF-8” as the encoding. It won’t throw that exception.
I could just surround the darn thing with a catch block that does nothing, but then in whatever freak case does cause the exception to be thrown, I won’t find out about it. I do not want to create a big chain of throws UnsupportedEncodingException up to the top of my program, either.
What can I do here? Why am I forced to deal with some Exceptions, while others (e.g. IllegalArgumentException, NullPointerException) I’m allowed to ignore?
I think you need a better grasp of checked exceptions and their purpose in general, but that is for another question and answer. In this case what you do is: