public static boolean isValidCharset(String charset){
  try {
    Charset.forName(charset);
  }
 catch (  UnsupportedCharsetException e) {
    return false;
  }
  return true;
}

public static boolean isValidCharset ( String charset ) { try { Charset . forName ( charset ) ; } catch ( UnsupportedCharsetException e ) { return false ; } return true ; }
this methods tests if a charset is valid regarding the charset nio api .
