| java.lang.Object | |
| ↳ | java.util.Scanner |
A parser that parses a text string to primitive types with the help of regular expression. It supports localized number and various radixes. The input is broken into tokens by the delimiter pattern, which is whitespace by default. The primitive types can be got via corresponding next methods. If the token is not in valid format, an InputMissmatchException is thrown. For example: Scanner s = new Scanner("1A true"); System.out.println(s.nextInt(16)); System.out.println(s.nextBoolean()); The result: 26 true A scanner can find or skip specific pattern with no regard to the delimiter. All these methods and the various next and hasNext methods may block. Scanner is not thread-safe without external synchronization
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a scanner that uses File as its input.
| |||||||||||
Constructs a scanner that uses File as its input.
| |||||||||||
Constructs a scanner that uses String as its input.
| |||||||||||
Constructs a scanner that uses InputStream as its input.
| |||||||||||
Constructs a scanner that uses InputStream as its input.
| |||||||||||
Constructs a scanner that uses Readable as its input.
| |||||||||||
Constructs a scanner that uses ReadableByteChannel as its input.
| |||||||||||
Constructs a scanner that uses ReadableByteChannel as its input.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Closes the underlying input if the input implements Closeable.
| |||||||||||
Returns the
Pattern in use by this scanner. | |||||||||||
Tries to find the pattern in input.
| |||||||||||
Tries to find the pattern compiled from the specified string.
| |||||||||||
Tries to find the pattern in input from current position to the specified
horizon.
| |||||||||||
Tries to find the pattern in input from current position to the specified
horizon.
| |||||||||||
Returns true if this scanner's next token matches the specified pattern.
| |||||||||||
Returns true if this scanner's next token matches the pattern constructed
from the specified string.
| |||||||||||
Returns true if this scanner has next token.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
BigDecimal.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
BigInteger in the default radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
BigInteger in the specified radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
boolean value.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
byte value in the specified radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
byte value in the default radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
double value.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
float value.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
int value in the default radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
int value in the specified radix.
| |||||||||||
Returns true if there is another line in the input.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
long value in the default radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
long value in the specified radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
short value in the specified radix.
| |||||||||||
Returns true if this scanner's next token can be translated into a valid
short value in the default radix.
| |||||||||||
Returns the last IOException thrown when reading the underlying input.
| |||||||||||
Return the locale of this scanner.
| |||||||||||
Returns the match result of this scanner's last match operation.This
method throws IllegalStateException if no match operation has been
performed, or if the last match was unsuccessful.
| |||||||||||
Returns the next token which is prefixed and postfixed by input that
matches the delimiter pattern if this token matches the pattern
constructed from the sepcified string.
| |||||||||||
Returns the next token which is prefixed and postfixed by input that
matches the delimiter pattern if this token matches the specified
pattern.
| |||||||||||
Finds and Returns the next complete token which is prefixed and postfixed
by input that matches the delimiter pattern.
| |||||||||||
Translates the next token in this scanner's input into a BigDecimal and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a BigInteger and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a BigInteger and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a boolean value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a byte value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a byte value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a double value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a float value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into an int value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into an int value and
returns this value.
| |||||||||||
Returns the skipped input and advances the scanner to the beginning of
the next line.
| |||||||||||
Translates the next token in this scanner's input into a long value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a long value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a short value and
returns this value.
| |||||||||||
Translates the next token in this scanner's input into a short value and
returns this value.
| |||||||||||
Return the radix of this scanner.
| |||||||||||
The operation of remove is not supported by this implementation of
Iterator.
| |||||||||||
Tries to use specified pattern to match input from the current position.
| |||||||||||
Tries to use the specified string to construct a pattern.
| |||||||||||
Returns a string.
| |||||||||||
Set the delimiting pattern of this scanner
| |||||||||||
Set the delimiting pattern of this scanner with a pattern compiled from
the supplied string value
| |||||||||||
Set the locale of this scanner to a specified locale.
| |||||||||||
Set the radix of this scanner to a specified radix.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.util.Iterator
| |||||||||||
Constructs a scanner that uses File as its input. The default charset is applied when reading the file.
| src | the file to be scanned |
|---|
| FileNotFoundException | if the specified file is not found |
|---|
Constructs a scanner that uses File as its input. The specified charset is applied when reading the file.
| src | the file to be scanned |
|---|---|
| charsetName | the name of the encoding type of the file |
| FileNotFoundException | if the specified file is not found |
|---|---|
| IllegalArgumentException | if the specified coding does not exist |
Constructs a scanner that uses String as its input.
| src | the string to be scanned |
|---|
Constructs a scanner that uses InputStream as its input. The default charset is applied when decoding the input.
| src | the input stream to be scanned |
|---|
Constructs a scanner that uses InputStream as its input. The specified charset is applied when decoding the input.
| src | the input stream to be scanned |
|---|---|
| charsetName | the encoding type of the input stream |
| IllegalArgumentException | if the specified character set is not found |
|---|
Constructs a scanner that uses Readable as its input.
| src | the Readable to be scanned |
|---|
Constructs a scanner that uses ReadableByteChannel as its input. The default charset is applied when decoding the input.
| src | the ReadableByteChannel to be scanned |
|---|
Constructs a scanner that uses ReadableByteChannel as its input. The specified charset is applied when decoding the input.
| src | the ReadableByteChannel to be scanned |
|---|---|
| charsetName | the encoding type of the content in the ReadableByteChannel |
| IllegalArgumentException | if the specified character set is not found |
|---|
Closes the underlying input if the input implements Closeable. If the scanner has been closed, this method will take no effect. The scanning operation after calling this method will throw IllegalStateException
Returns the Pattern in use by this scanner.
Pattern presently in use by this scanner
Tries to find the pattern in input. Delimiters are ignored. If the pattern is found before line terminator, the matched string will be returned, and the scanner will advance to the end of the matched string. Otherwise, null will be returned and the scanner will not advance the input. When waiting for input, the scanner may be blocked. All the input may be cached if no line terminator exists in the buffer.
| pattern | the pattern used to match input |
|---|
| IllegalStateException | if the scanner is closed |
|---|
Tries to find the pattern compiled from the specified string. The delimiter will be ignored. It is the same as invoke findInLine(Pattern.compile(pattern))
| pattern | a string used to construct a pattern which in turn used to match input |
|---|
| IllegalStateException | if the scanner is closed |
|---|
Tries to find the pattern in input from current position to the specified horizon. Delimiters are ignored. If the pattern is found, the matched string will be returned, and the scanner will advance to the end of the matched string. Otherwise, null will be returned and scanner will not advance the input. When waiting for input, the scanner may be blocked. Scanner will never search exceed horizon code points from current position. The position of horizon does have effects on the result of match. For example, when input is "123", and current position is at zero, findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 2) will return null. While findWithinHorizon(Pattern.compile("\\p{Digit}{3}"), 3) will return "123". Horizon is treated as a transparent, non-anchoring bound. (refer to useTransparentBounds(boolean) and useAnchoringBounds(boolean)) Horizon whose value is zero will be ignored and the whole input will be used for search. Under this situation, all the input may be cached. An IllegalArgumentException will be thrown out if horizon is less than zero.
| pattern | the pattern used to scan |
|---|---|
| horizon | the search limit |
| IllegalStateException | if the scanner is closed |
|---|---|
| IllegalArgumentException | if horizon is less than zero |
Tries to find the pattern in input from current position to the specified horizon. Delimiters are ignored. It is the same as invoke findWithinHorizon(Pattern.compile(pattern)).
| pattern | the pattern used to scan |
|---|---|
| horizon | the search limit |
| IllegalStateException | if the scanner is closed |
|---|---|
| IllegalArgumentException | if horizon is less than zero |
Returns true if this scanner's next token matches the specified pattern. This method may be blocked when it is waiting for input to scan. This scanner does not advance past the input that matched the pattern.
| pattern | the specified pattern to scan |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token matches the pattern constructed from the specified string. This method may be blocked when it is waiting for input to scan. This scanner does not advance past the input that matched the pattern. The invocation of this method in the form hasNext(pattern) behaves in the same way as the invocation of hasNext(Pattern.compile(pattern)).
| pattern | the string specifying the pattern to scan for |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner has next token. This method may be blocked when it is waiting for input to scan. This scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid BigDecimal. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid BigInteger in the default radix. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid BigInteger in the specified radix. The scanner does not advance past the input.
| radix | the radix used to translate the token into a BigInteger |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid boolean value. The scanner does not advance past the input that matched.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid byte value in the specified radix. The scanner does not advance past the input.
| radix | the radix used to translate the token into a byte value |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid byte value in the default radix. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid double value. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid float value. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid int value in the default radix. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid int value in the specified radix. The scanner does not advance past the input.
| radix | the radix used to translate the token into an int value |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if there is another line in the input. Otherwise, returns false. When waiting for input, the scanner may be blocked. No matter true or false, the scanner will not advance any input.
| IllegalStateException | if the scanner is closed |
|---|
Returns true if this scanner's next token can be translated into a valid long value in the default radix. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid long value in the specified radix. The scanner does not advance past the input.
| radix | the radix used to translate the token into a long value |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid short value in the specified radix. The scanner does not advance past the input.
| radix | the radix used to translate the token into a short value |
|---|
| IllegalStateException | if the scanner has been closed |
|---|
Returns true if this scanner's next token can be translated into a valid short value in the default radix. The scanner does not advance past the input.
| IllegalStateException | if the scanner has been closed |
|---|
Returns the last IOException thrown when reading the underlying input. If no exception is thrown, return null.
Return the locale of this scanner.
Returns the match result of this scanner's last match operation.This method throws IllegalStateException if no match operation has been performed, or if the last match was unsuccessful. The various nextXXX methods of Scanner provide a match result if they do not complete with throwing an exception. For example, after an invocation of the nextBoolean() method which returned a boolean value, this method returns a match result for the search of the Boolean regular expression defined above. In the same way,the findInLine(java.lang.String), findWithinHorizon(java.lang.String, int), and skip(java.util.regex.Pattern) methods will provide a match result if they are successful.
| IllegalStateException | if the match result is not available |
|---|
Returns the next token which is prefixed and postfixed by input that matches the delimiter pattern if this token matches the pattern constructed from the sepcified string. This method may be blocked when it is waiting for input to scan. If this match successes, the scanner advances past the next token that matched the pattern. The invocation of this method in the form next(pattern) behaves in the same way as the invocation of next(Pattern.compile(pattern)).
| pattern | the string specifying the pattern to scan for |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
Returns the next token which is prefixed and postfixed by input that matches the delimiter pattern if this token matches the specified pattern. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNext(Pattern) returned true. If this match successes, the scanner advances past the next token that matched the pattern.
| pattern | the specified pattern to scan |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
Finds and Returns the next complete token which is prefixed and postfixed by input that matches the delimiter pattern. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNext() returned true. If this match successes, the scanner advances past the next complete token.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
Translates the next token in this scanner's input into a BigDecimal and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextBigDecimal() returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Float regular expression successfully, the token is translated into a BigDecimal as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to BigDecimal(String)}.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid BigDecimal |
Translates the next token in this scanner's input into a BigInteger and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextBigInteger() returned true. If this match succeeds, the scanner advances past the input that matched. The invocation of this method in the form nextBigInteger() behaves in the same way as the invocation of nextBigInteger(radix), the radix is the default radix of this scanner.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid BigInteger, or it is out of range |
Translates the next token in this scanner's input into a BigInteger and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextBigInteger(radix) returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Integer regular expression successfully, the token is translated into a BigInteger as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to BigInteger(String, int)} with the specified radix.
| radix | the radix used to translate the token into a BigInteger |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid BigInteger, or it is out of range |
Translates the next token in this scanner's input into a boolean value and returns this value. This method will throw InputMismatchException if the next token can not be interpreted as a boolean value with a case insensitive pattern created from the string "true|false". If this match succeeds, the scanner advances past the input that matched.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid boolean value |
Translates the next token in this scanner's input into a byte value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextByte() returned true. If this match succeeds, the scanner advances past the input that matched. The invocation of this method in the form nextByte() behaves in the same way as the invocation of nextByte(radix), the radix is the default radix of this scanner.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid byte value, or it is out of range |
Translates the next token in this scanner's input into a byte value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextByte(radix) returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Integer regular expression successfully, the token is translated into a byte value as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to parseByte(String, int)} with the specified radix.
| radix | the radix used to translate the token into byte value |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid byte value, or it is out of range |
Translates the next token in this scanner's input into a double value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextDouble() returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Float regular expression successfully, the token is translated into a double value as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to parseDouble(String)}.If the token matches the localized NaN or infinity strings, it is also passed to parseDouble(String)}.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid double value |
Translates the next token in this scanner's input into a float value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextFloat() returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Float regular expression successfully, the token is translated into a float value as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to parseFloat(String)}.If the token matches the localized NaN or infinity strings, it is also passed to parseFloat(String)}.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid float value |
Translates the next token in this scanner's input into an int value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextInt() returned true. If this match succeeds, the scanner advances past the input that matched. The invocation of this method in the form nextInt() behaves in the same way as the invocation of nextInt(radix), the radix is the default radix of this scanner.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid int value |
Translates the next token in this scanner's input into an int value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextInt(radix) returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Integer regular expression successfully, the token is translated into an int value as following steps. At first all locale specific prefixes ,group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via Character.digit, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to Integer.parseInt with the specified radix.
| radix | the radix used to translate the token into an int value |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid int value |
Returns the skipped input and advances the scanner to the beginning of the next line. The returned result will exclude any line terminator. When searching, if no line terminator is found, then a large amount of input will be cached. If no line at all can be found, a NoSuchElementException will be thrown out.
| IllegalStateException | if the scanner is closed |
|---|---|
| NoSuchElementException | if no line can be found, e.g. when input is an empty string |
Translates the next token in this scanner's input into a long value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextLong(radix) returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Integer regular expression successfully, the token is translated into a long value as following steps. At first all locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to parseLong(String, int)} with the specified radix.
| radix | the radix used to translate the token into a long value |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid long value, or it is out of range |
Translates the next token in this scanner's input into a long value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextLong() returned true. If this match succeeds, the scanner advances past the input that matched. The invocation of this method in the form nextLong() behaves in the same way as the invocation of nextLong(radix), the radix is the default radix of this scanner.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid long value, or it is out of range |
Translates the next token in this scanner's input into a short value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextShort() returned true. If this match succeeds, the scanner advances past the input that matched. The invocation of this method in the form nextShort() behaves in the same way as the invocation of nextShort(radix), the radix is the default radix of this scanner.
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid short value, or it is out of range |
Translates the next token in this scanner's input into a short value and returns this value. This method may be blocked when it is waiting for input to scan, even if a previous invocation of hasNextShort(radix) returned true. If this match succeeds, the scanner advances past the input that matched. If the next token matches the Integer regular expression successfully, the token is translated into a short value as following steps. At first all locale specific prefixes, group separators, and locale specific suffixes are removed. Then non-ASCII digits are mapped into ASCII digits via digit(char, int)}, a negative sign (-) is added if the locale specific negative prefixes and suffixes were present. At last the resulting String is passed to parseShort(String, int)} with the specified radix.
| radix | the radix used to translate the token into short value |
|---|
| IllegalStateException | if this scanner has been closed |
|---|---|
| NoSuchElementException | if input has been exhausted |
| InputMismatchException | if the next token can not be translated into a valid short value, or it is out of range |
Return the radix of this scanner.
The operation of remove is not supported by this implementation of Iterator.
| UnsupportedOperationException | if this method is invoked |
|---|
Tries to use specified pattern to match input from the current position. The delimiter will be ignored. If matches, the matched input will be skipped. If an anchored match of the specified pattern succeeds, input will also be skipped. Otherwise, a NoSuchElementException will be thrown out. Patterns that can match a lot of input may cause the scanner to read in a large amount of input. Uses a pattern that matches nothing( sc.skip(Pattern.compile("[ \t]*")) ) will suppress NoSuchElementException.
| pattern | used to skip over input |
|---|
| IllegalStateException | if the scanner is closed |
|---|---|
| NoSuchElementException | if the specified pattern match fails |
Tries to use the specified string to construct a pattern. And then uses the constructed pattern to match input from the current position. The delimiter will be ignored. It is the same as invoke skip(Pattern.compile(pattern))
| pattern | the string used to construct a pattern which in turn used to match input |
|---|
| IllegalStateException | if the scanner is closed |
|---|
Returns a string. The string is used to represent this scanner. Contained information may be helpful for debugging. The format of the string is unspecified.
Set the delimiting pattern of this scanner
| pattern | the delimiting pattern to use |
|---|
Set the delimiting pattern of this scanner with a pattern compiled from the supplied string value
| pattern | a string from which a Pattern can be compiled |
|---|
Set the locale of this scanner to a specified locale.
| l | the specified locale to use |
|---|
Set the radix of this scanner to a specified radix.
| radix | the specified radix to use |
|---|