java.nio.charset.IllegalCharsetNameException: UTF-8

If you get an IllegalCharsetNameException with an obviously correct charset (It also can happen with any ISO charset like ISO-8859-1), you definitely should check if there are any preceding or subsequent characters like a space for example. Also no quotations are allowed, e.g. "UTF-8". 

Exception in thread "main" java.nio.charset.IllegalCharsetNameException: UTF-8 
at java.nio.charset.Charset.checkName(Charset.java:315)
at java.nio.charset.Charset.lookup2(Charset.java:484)
at java.nio.charset.Charset.lookup(Charset.java:464)
at java.nio.charset.Charset.isSupported(Charset.java:505)

Leave a Comment

comments powered by Disqus