Scanner class methods in Java Part -III

java.util.Scanner

A simple text scanner that can parse primitive types and strings using regular expressions.

A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.


Some methods of Scanner class.


nextByte(int): This method scans the next token of the input as a byte.


nextDouble(): This method scans the next token of the input as a double.


nextFloat(): This method scans the next token of the input as a float.


nextInt(): This method scans the next token of the input as an int.


nextInt(int): This method scans the next token of the input as an int according to the specified radix.


nextLine(): This method advances this scanner past the current line and returns the input that was skipped.


nextLong(): This method scans the next token of the input as a long.


nextLong(int): This method scans the next token of the input as a long according to the specified radix.


nextShort(): This method scans the next token of the input as a short.


nextShort(int): This method scans the next token of the input as a short according to the specified radix.

radix(): This method returns this scanner's default radix.


remove(): The remove operation is not supported by this implementation of Iterator.


reset(): This method resets this scanner.


skip(Pattern): This method skips input that matches the specified pattern, ignoring delimiters.


skip(String): This method skips input that matches a pattern constructed from the specified string.


tokens(): This method returns a stream of delimiter-separated tokens from this scanner.


toString(): This method returns the string representation of this Scanner.


useDelimiter(Pattern): This method sets this scanner's delimiting pattern to the specified pattern.


useDelimiter(String): This method sets this scanner's delimiting pattern to a pattern constructed from the specified String.


useLocale(Locale): This method sets this scanner's locale to the specified locale.


useRadix(int): This method sets this scanner's default radix to the specified radix.


Some more methods of Scanner class -I


Some more methods of Scanner class -II


No comments:

Post a Comment