Code example for InputMismatchException

0
 
    public static void verifyTitleID(String toVerify) throws InputMismatchException {
        Pattern pattern = Pattern.compile("^[A-Za-z0-9_]+$");
        Matcher matcher = pattern.matcher(toVerify);
        if (!matcher.find())
            throw new InputMismatchException("Title ID can only contain alphanumberic characters and underscores.");
    } 
 
    public static void main(String[] args) {
        Logger.setLevel(Logger.DEBUG);
        if (args.length < 1)
            printHelp(); 
        String toDo = args[0];
        try { 
            if (toDo.equals("extract") || toDo.equals("x"))
                doExtractData(args);
            if (toDo.equals("convert") || toDo.equals("c"))
                doConvertImage(args);
            if (toDo.equals("decompress") || toDo.equals("d"))
                doDecompressImage(args);