Scanner class methods in Java Part -I

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.


close()This method closes this scanner.


delimiter()This method returns the Pattern this Scanner is currently using to match delimiters.


equals(Object)This method indicates whether some other object is "equal to" this one.


findAll(Pattern)This method returns a stream of match results from this scanner.


findAll(String)This method returns a stream of match results that match the provided pattern string.


findInLine(Pattern)This method attempts to find the next occurrence of the specified pattern ignoring delimiters.


findInLine(String)This method attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.


findWithinHorizon(Pattern, int)This method attempts to find the next occurrence of the specified pattern.



findWithinHorizon(String, int)This method attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.


forEachRemaining(Consumer)This method performs the given action for each remaining element until all elements have been processed or the action throws an exception.


hashCode()This method returns a hash code value for the object.


hasNext()This method returns true if this scanner has another token in its input.


hasNext(Pattern)This method returns true if the next complete token matches the specified pattern.


hasNext(String)This method returns true if the next token matches the pattern constructed from the specified string.


hasNextBigDecimal()This method returns true if the next token in this scanner's input can be interpreted as a BigDecimal.


hasNextBigInteger()This method returns true if the next token in this scanner's input can be interpreted as a BigInteger in the default radix.


hasNextBigInteger(int)This method returns true if the next token in this scanner's input can be interpreted as a BigInteger in the specified radix.


hasNextBoolean()This method returns true if the next token in this scanner's input can be interpreted as a boolean value using a case insensitive pattern created from the string "true|false".



hasNextByte()This method returns true if the next token in this scanner's input can be interpreted as a byte value in the default radix.


hasNextByte(int)This method returns true if the next token in this scanner's input can be interpreted as a byte value in the specified radix.


Some more methods of Scanner class -II


Some more methods of Scanner class -III




No comments:

Post a Comment