public static boolean isSupported(String charsetName) {
        try {
            if (isSupportedICU != null && (Boolean) isSupportedICU.invoke(null, charsetName)) {
                return true;
            }
            return Charset.isSupported(charsetName);
        } catch (IllegalCharsetNameException e) {
            return false;
        } catch (IllegalArgumentException e) {
            // null, for example
            return false;
        } catch (Exception e) {
            // Unexpected exception, what to do?
            return false;
        }
    }
Safely return whether <charsetName> is supported, without throwing exceptions

@param charsetName Name of charset (can be null)
@return true if the character set is supported
tika-core/src/main/java/org/apache/tika/utils/CharsetUtils.java