Code example for Scanner

Methods: nextLonguseLocale

0
        assertEquals(23456, s.nextLong(10));
 
        /* 
         * ''' is used in many locales as group separator. 
         */ 
        s = new Scanner("23'456 23'456");
        s.useLocale(Locale.GERMANY);
        try { 
            s.nextLong(10);
            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(23456, s.nextLong(10));
        assertEquals(23456, s.nextLong(10));
 
        /* 
         * The input string has Arabic-Indic digits. 
         */ 
        s = new Scanner("1\u06602 1\u06662");