Duvida InputMismatchException e nextInt Scanner

String csv = ?Sue,5,true,3?;
Scanner scanner = new Scanner( csv);
scanner.useDelimiter(?,?);
int age = scanner.nextInt();

Porque esta lançando InputMismatchException no nextInt??
E o que o nextInt realmente faz???

Documentação:

nextInt

public int nextInt(int radix)

Scans the next token of the input as an int. This method will throw InputMismatchException if the next token cannot be translated into a valid int value as described below. If the translation is successful, the scanner advances past the input that matched.

If the next token matches the Integer regular expression defined above then the token is converted into an int value as if by removing all locale specific prefixes, group separators, and locale specific suffixes, then mapping non-ASCII digits into ASCII digits via Character.digit, prepending a negative sign (-) if the locale specific negative prefixes and suffixes were present, and passing the resulting string to Integer.parseInt with the specified radix.

Parameters:
    radix - the radix used to interpret the token as an int value 
Returns:
    the int scanned from the input 
Throws:
    InputMismatchException - if the next token does not match the Integer regular expression, or is out of range 
    NoSuchElementException - if input is exhausted 
    IllegalStateException - if this scanner is closed

Mas mesmo assim não ficou claro para mim.

o método nextInt() = obtem o proximo token, retorna o valor do tipo int, e em seguida se move para o token seguinte.

No seu codigo, int age = scanner.nextInt(); está retornando o valor do primeiro token, que no caso é “Sue”, uma String e nao um int, por isso ele lança a excessão. Mas se o valor do primeiro token fosse um int, por exemplo: String csv = “6, Sue,5,true,3”; , entao nao seria lançada nenhuma excessão e o valor de age seria 6. Entendeu? Nao sou mto boa pra explicar, mas eh isso.
Se vc quiser usar essa String csv = “Sue,5,true,3”; o metodo a ser usado, deveria ser next(); que faz a mesma coisa que o metodo nextInt() só que ao invés de retornar um int, retorna uma String.

Muito obrigado Cris Finholdt