Thursday, April 10, 2014

Scanner Class - II


Some other useful Methods of the  Scanner Class :

Method Name
Defination
close()
Closes the scanner.
delimiter()
Returns the Pattern used by current Scanner object.
findInLine(Pattern pattern)
This method returns a String object that satisfies the Pattern.
findInLine(String pattern)
find the next occurrence of the specified pattern
findWithinHorizon(Pattern pattern, int horizon)
Find the next occurrence of the specified pattern.
findWithinHorizon(String pattern, int horizon)
Find the next occurrence of a pattern input ignoring delimiter
hasNext()
Returns true if this scanner has another token.
hasNext(Pattern pattern)
Returns true if the next token matches the specified pattern.
hasNext(String pattern)
Returns true if the next token matches the pattern constructed from the specified string.
hasNextBigDecimal()
Returns true if the next token in this scanner's input can be interpreted as a BigDecimal using the nextBigDecimal() method.
hasNextBigInteger()
Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the default radix using the nextBigInteger() method.
hasNextBigInteger(int radix)
Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the specified radix using the nextBigInteger() method.
hasNextBoolean()
This method checks if the Scanner object has boolean data type on its buffer.
hasNextByte()
This method returns true if the next byte on the scanner buffer can be translated to byte data type otherwise false.
hasNextByte(int radix)
Returns true if the next token in this scanner's input can be interpreted as a byte value in the specified.
hasNextDouble()
Returns true if the next token in this scanner's input can be interpreted as a double value using the nextDouble() method.
hasNextFloat()
Returns true if the next token in this scanner's input can be interpreted as a float value using the nextFloat() method.
hasNextInt()
Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method.
hasNextInt(int radix)
This method returns boolean, true if the token can be interpreted as int data type with respect to the radix used by the scanner object otherwise false.
hasNextLine()
This method returns a boolean data type which corresponds to the existence of new line on the String tokens which the Scanner object holds.
hasNextLong()
Returns true if the next token in this scanner's input can be interpreted as a long value in the default radix using the nextLong() method.
hasNextLong(int radix)
Returns true if the next token in this scanner's input can be interpreted as a long value in the specified radix using the nextLong() method.
hasNextShort()
Returns true if the next token in this scanner's input can be interpreted as a short value in the default radix using the nextShort() method.
hasNextShort(int radix)
This method returns boolean, true if the token can be interpreted as short data type with respect to the radix used by the scanner object otherwise false.
ioException()
Returns the IOException last thrown by this Scanner's underlying Readable.
locale()
This method returns a Locale which the Scanner class is using.
match()
This method returns a MatchResult object which corresponds to the result of the last operation by the scanner object.
next(Pattern pattern)
Returns the next token if it matches the specified pattern.
radix()
Returns this scanner's default radix.
remove()
The remove operation is not supported by this implementation of Iterator.
reset()
Resets this scanner.
skip(Pattern pattern)
Skips input that matches the specified pattern, ignoring delimiters.
skip(String pattern)
Skips input that matches a pattern constructed from the specified string.
toString()
Returns the string representation of this Scanner.
useDelimiter(Pattern pattern)
Sets this scanner's delimiting pattern to the specified pattern.
useDelimiter(String pattern)
Sets this scanner's delimiting pattern to a pattern constructed from the specified String.
useLocale(Locale locale)
Sets this scanner's locale to the specified locale.
useRadix(int radix)
Sets this scanner's default radix to the specified radix.

No comments: