Code example for Scanner

Methods: nextInt, useLocale, useRadix

0
        } catch (InputMismatchException e) {
            // Expected 
        } 
 
        // If the number is out of range 
        s = new Scanner("123456789123456789123456789123456789");
        try { 
            s.nextInt();
            fail("Should throw InputMismatchException");
        } catch (InputMismatchException e) {
            // Expected 
        } 
 
        /* 
         * Different locale can only recognize corresponding locale sensitive 
         * string. ',' is used in many locales as group separator. 
         */ 
        s = new Scanner("23,456 23,456");
        s.useLocale(Locale.GERMANY);
        try { 
            s.nextInt();