Code example for Scanner

Methods: hasNextInt, nextInt, useLocale, useRadix

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