code: private static Charset toCharset(String csn)
          throws UnsupportedEncodingException
      {
          Objects.requireNonNull(csn, "charsetName");
          try {
              return Charset.forName(csn);
          } catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
              // UnsupportedEncodingException should be thrown
              throw new UnsupportedEncodingException(csn);
          }
      }
docs: Returns a charset object for the given charset name.
  @throws NullPointerException          is csn is null
  @throws UnsupportedEncodingException  if the charset is not supported