java.util
public class Scanner extends Object implements Iterator<String>
Constructor Summary | |
---|---|
Scanner(File source)
Constructs a new Scanner with the given File as source.
Scanner | |
Scanner(File source, String charsetName)
Constructs a new Scanner with the given File as source. | |
Scanner(InputStream source)
Constructs a new Scanner with the given inputStream. | |
Scanner(InputStream source, String charsetName)
Constructs a new Scanner with the InputSream and a charsetName. | |
Scanner(Readable source)
Constructs a new Scanner with a Readable input as source.
| |
Scanner(ReadableByteChannel source)
Constructs a new Scanner with a ReadableByteChannel as
source. | |
Scanner(ReadableByteChannel source, String charsetName)
Constructs a new Scanner with a ReadableByteChannel as source and
a given charsetName, which is to be applied on it. | |
Scanner(String source)
Constructs a new Scanner using the given String as input only.
|
Method Summary | |
---|---|
void | close()
Closes this Scanner. |
Pattern | delimiter()
Returns the current delimiter.
|
String | findInLine(Pattern pattern)
Tries to find the pattern in the current line.
|
String | findInLine(String pattern)
Compiles the given pattern into a Pattern and calls
findInLine with the compiled pattern and
returns whatever it returns.
|
String | findWithinHorizon(Pattern pattern, int horizon)
Trys to match the pattern within the given horizon.
|
String | findWithinHorizon(String pattern, int horizon)
Compile the pattern and call Scanner.
|
boolean | hasNext()
Checks if there is any next String using the current
delimiter. |
boolean | hasNext(Pattern pattern)
Searches the pattern in the next subString before the next
current delimiter.
|
boolean | hasNext(String pattern)
Compiles the pattern to a Pattern and calls hasNext.
|
boolean | hasNextBigDecimal()
Checks if the string to the next delimiter can be interpreted as
a BigDecimal number. |
boolean | hasNextBigInteger()
Checks if the string to the next delimiter can be interpreted as
a BigInteger number. |
boolean | hasNextBigInteger(int radix)
Checks if the string to the next delimiter can be interpreted as
a BigInteger number. |
boolean | hasNextBoolean()
Checks if the next string could be a boolean. |
boolean | hasNextByte()
Checks if the string to the next delimiter can be interpreted as
a byte number. |
boolean | hasNextByte(int radix)
Checks if the string to the next delimiter can be interpreted as
a byte number with the given radix. |
boolean | hasNextDouble()
Checks if the string to the next delimiter can be interpreted as
a double number. |
boolean | hasNextFloat()
Checks if the string to the next delimiter can be interpreted as
a double number. |
boolean | hasNextInt()
Checks if the string to the next delimiter can be interpreted as
an int number. |
boolean | hasNextInt(int radix)
Checks if the string to the next delimiter can be interpreted as
an int number with the given radix. |
boolean | hasNextLine()
Checks if there is a current line, which ends at the next line
break or the end of the input.
|
boolean | hasNextLong()
Checks if the string to the next delimiter can be interpreted as
a long number. |
boolean | hasNextLong(int radix)
Checks if the string to the next delimiter can be interpreted as
a long number with the given radix. |
boolean | hasNextShort()
Checks if the string to the next delimiter can be interpreted as
a short number with the given radix. |
boolean | hasNextShort(int radix)
Checks if the string to the next delimiter can be interpreted as
a short number. |
IOException | ioException()
Returns the last IOException occured.
|
boolean | isUseLocale()
Returns the current value of useLocale. |
Locale | locale()
Returns the current Locale. |
MatchResult | match()
Returns the last MatchResult found. |
String | next()
Uses the current delimiter to find the next string in the
buffer. |
String | next(Pattern pattern)
Tries to match the buffer with the given pattern. |
String | next(String pattern)
Tries to match the buffer with the given pattern. |
BigDecimal | nextBigDecimal()
Tries to interpret the next string as a BigDecimal value.
|
BigInteger | nextBigInteger()
Tries to interpret the next string as a BigInteger value. |
BigInteger | nextBigInteger(int radix)
Tries to interpret the next string as a BigInteger value with the
given radix.
|
boolean | nextBoolean()
Tries to interpret the next string to the delimiter as a boolean
value, ignoring case.
|
byte | nextByte()
Tries to interpret the next string as a byte value. |
byte | nextByte(int radix)
Tries to interpret the next string as a byte value with the given
radix.
|
double | nextDouble()
Tries to interpret the next string as a double value.
|
float | nextFloat()
Tries to interpret the next string as a double value, and then
casts down to float.
|
int | nextInt()
Tries to interpret the next string as an int value. |
int | nextInt(int radix)
Tries to interpret the next string as an int value with the given
radix.
|
String | nextLine()
Tries to match the system line seperator, and returns the current
line.
|
long | nextLong()
Tries to interpret the next string as a long value. |
long | nextLong(int radix)
Tries to interpret the next string as a long value with the given
radix.
|
short | nextShort()
Tries to interpret the next string as a short value. |
short | nextShort(int radix)
Tries to interpret the next string as a short value with the
given radix.
|
int | radix() |
void | remove()
The remove operation is not supported by this implementation of
Iterator. |
void | setUseLocale(boolean useLocale) |
Scanner | skip(Pattern pattern)
Skips the given pattern. |
Scanner | skip(String pattern)
Skips a given pattern. |
Scanner | useDelimiter(Pattern pattern)
Sets the current pattern to the given parameter, and updates the
Matcher with the new pattern.
|
Scanner | useDelimiter(String pattern)
Sets the current pattern to the given parameter. |
Scanner | useLocale(Locale locale)
Sets the current Locale to the given parameter. |
Scanner | useRadix(int radix)
Sets the current radix to the current value if the given radix is
>= 2 and <= 36 otherwise an IllegalArgumentException is
thrown.
|
null
as charsetName.
Parameters: source The File to use as source.
Throws: FileNotFoundException If the file is not found an Exception is thrown.
Parameters: source The File to use as source. charsetName Current charset name of the file. If charsetName is null it behaves if it was not set.
Throws: FileNotFoundException If the file is not found an Exception is thrown.
null
as charsetName.
Parameters: source The InputStream to use as source.
Parameters: source The InputStream to use as source. charsetName The charsetName to apply on the source's data.
Parameters: source The Readable to use as source.
null
as charsetName.
Parameters: source The ReadableByteChannel to use as source.
Parameters: source The ReadableByteChannel to use as source. charsetName The charsetName to be applied on the source.
Parameters: source The whole String to be used as source.
Returns: the current delimiter.
Parameters: pattern The pattern which should be searched in the current line of the input.
Returns: If the search was successful, the result or otherwise a NoSuchElementException is thrown.
Throws: NoSuchElementException If the pattern was not found.
Parameters: pattern The pattern which should be matched in the input.
Returns: The match in the current line.
Throws: NoSuchElementException If the pattern was not found.
Parameters: pattern Pattern to search. horizon
Returns: The result of the match.
Throws: IllegalArgumentException if the horizon is negative. IllegalStateException if the Scanner is closed.
Parameters: pattern Pattern to search. horizon
Returns: The result of the match.
Throws: IllegalArgumentException if the horizon is negative. IllegalStateException if the Scanner is closed.
null
and the length must be greater then 0. If a NoSuchElementException is thrown by the search method, it is
catched and false is returned.
Returns: true
if there is any result using the current delimiter. This wouldn't
lead to a NoSuchElementException.
Throws: IllegalStateException if the Scanner is closed.
Parameters: pattern The pattern to search for.
Returns: true
if the pattern is found before the current delimiter.
Throws: IllegalStateException if the Scanner is closed.
Parameters: pattern The pattern as string to search for.
Returns: true
if the pattern is found before the current delimiter.
Throws: IllegalStateException if the Scanner is closed.
See Also: hasNext
Returns: true
if the next string is a BigDecimal number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextBigDecimal
Returns: true
if the next string is a BigInteger number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextBigInteger
Parameters: radix The radix to use for this check. The global radix of the Scanner will not be changed.
Returns: true
if the next string is a BigInteger number.
Throws: IllegalStateException if the Scanner is closed.
true
.
Returns: Return true
if the next string is a boolean.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextBoolean
Returns: true
if the next string is a byte number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextByte
Parameters: radix The radix to use for this check. The global radix of the Scanner will not be changed.
Returns: true
if the next string is a byte number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Returns: true
if the next string is a double number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextDouble
Returns: true
if the next string is a double number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextFloat
Returns: true
if the next string is an int number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to use for this check. The global radix of the Scanner will not be changed.
Returns: true
if the next string is an int number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Returns: true
if there is a current line.
Throws: IllegalStateException if the Scanner is closed.
Returns: true
if the next string is a long number.
Throws: IllegalStateException if the Scanner is closed.
See Also: nextLong
Parameters: radix The radix to use for this check. The global radix of the Scanner will not be changed.
Returns: true
if the next string is a long number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Returns: true
if the next string is a short number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to use for this check. The global radix of the Scanner will not be changed.
Returns: true
if the next string is a short number.
Throws: IllegalStateException if the Scanner is closed.
See Also: Scanner
Returns: Returns the last IOException.
Returns: the useLoclae.
See Also: Scanner
Returns: Returns the current Locale.
See Also: useLocale
Returns: Returns the last MatchResult found.
Returns: Returns the next string of the buffer.
Throws: NoSuchElementException If no element was found an exception is thrown. IllegalStateException If the Scanner is closed.
See Also: match
Parameters: pattern The pattern to match.
Returns: Returns the next string matching the pattern.
Throws: NoSuchElementException If no element was found an exception is thrown. IllegalStateException If the Scanner is closed.
Parameters: pattern The pattern to match.
Returns: Returns the next string matching the pattern.
Throws: NoSuchElementException If no element was found an exception is thrown. IllegalStateException If the Scanner is closed.
See Also: next
Returns: Returns the BigDecimal value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a BigDecimal. IllegalStateException If the Scanner is closed.
Returns: Returns the BigInteger value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a BigInteger. IllegalStateException If the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to be used for this BigInteger. The current radix of the Scanner is not changed.
Returns: Returns the BigInteger value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a BigInteger. IllegalStateException If the Scanner is closed.
Returns: Returns the boolean value of the next matching string or throws an exception.
Throws: NoSuchElementException If no string is found or the string is not a boolean. IllegalStateException If the Scanner is closed.
Returns: Returns the byte value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a byte IllegalStateException If the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to be used for this byte. The current radix of the Scanner is not changed.
Returns: Returns the byte value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a byte. IllegalStateException If the Scanner is closed.
Returns: Returns the int value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a double. IllegalStateException If the Scanner is closed.
Returns: Returns the int value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a double. IllegalStateException If the Scanner is closed.
Returns: Returns the int value of the next string.
Throws: NoSuchElementException If no string is found or the string is not an int. IllegalStateException If the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to be used for this int. The current radix of the Scanner is not changed
Returns: Returns the int value of the next string.
Throws: NoSuchElementException If no string is found or the string is not an int. IllegalStateException If the Scanner is closed.
Returns: Returns the current line.
Throws: NoSuchElementException If the current delimiter is not found. IllegalStateException If the Scanner is closed.
Returns: Returns the long value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a long. IllegalStateException If the Scanner is closed.
See Also: Scanner
Parameters: radix The radix to be used for this long. The current radix of the Scanner is not changed
Returns: Returns the long value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a long. IllegalStateException If the Scanner is closed.
Returns: Returns the short value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a short.
See Also: Scanner
Parameters: radix The radix to be used for this short. The current radix of the Scanner is not changed.
Returns: Returns the short value of the next string.
Throws: NoSuchElementException If no string is found or the string is not a short.
Returns: Returns the current radix.
Parameters: useLocale the useLocale to set.
true
.
Parameters: pattern Pattern which should be skipped.
Returns: this
with the skipped buffer.
Throws: NoSuchElementException If the Pattern is not found.
Parameters: pattern Pattern which should be skipped.
Returns: this
with the skipped buffer.
See Also: skip
Parameters: pattern The new pattern to use.
Returns: Returns the Scanner (this
) with the new pattern.
Parameters: pattern The new pattern to use.
Returns: Returns the Scanner (this
) with the new pattern.
See Also: useDelimiter
Parameters: locale The new Locale to use. If it is null
nothing happens.
Returns: Returns the Scanner (this
) with the new Locale.
Parameters: radix the new radix to use as default.
Returns: this
with the new radix value.
Throws: IllegalArgumentException When the given radix is out of bounds.