Code example for Scanner

Methods: nextBigInteger, useLocale, useRadix

0
        assertEquals(new BigInteger("23456"), s.nextBigInteger());
 
        /* 
         * ''' is used in many locales as group separator. 
         */ 
        s = new Scanner("23'456 23'456");
        s.useLocale(Locale.GERMANY);
        try { 
            s.nextBigInteger();
            fail("Should throw InputMismatchException");
        } catch (InputMismatchException e) {
            // Expected 
        } 
        s.useLocale(new Locale("it", "CH"));
        // If exception is thrown out, input will not be advanced. 
        assertEquals(new BigInteger("23456"), s.nextBigInteger());
        assertEquals(new BigInteger("23456"), s.nextBigInteger());
 
        /* 
         * The input string has Arabic-Indic digits. 
         */ 
        s = new Scanner("1\u06602 1\u06662");