java.util
Class Scanner

java.lang.Object
  extended by java.util.Scanner
All Implemented Interfaces:
Iterator<String>

public class Scanner
extends Object
implements Iterator<String>


Constructor Summary
Scanner(File source)
          Constructs a new Scanner with the given File as source.
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(Pattern) 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 findWithinHorizon(Pattern, int).
 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(Pattern).
 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.
 String toString()
          Returns the string representation of this Scanner.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(File source)
        throws FileNotFoundException
Constructs a new Scanner with the given File as source. Scanner(InputStream, String) is called with null as charsetName.

Parameters:
source - The File to use as source.
Throws:
FileNotFoundException - If the file is not found an Exception is thrown.

Scanner

public Scanner(File source,
               String charsetName)
        throws FileNotFoundException
Constructs a new Scanner with the given File as source.
Scanner(InputStream, String) is called with the given charsetName.

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.

Scanner

public Scanner(InputStream source)
Constructs a new Scanner with the given inputStream.
Scanner(InputStream, String) is called with null as charsetName.

Parameters:
source - The InputStream to use as source.

Scanner

public Scanner(InputStream source,
               String charsetName)
Constructs a new Scanner with the InputSream and a charsetName. Afterwards the Buffer is filled.

Parameters:
source - The InputStream to use as source.
charsetName - The charsetName to apply on the source's data.

Scanner

public Scanner(Readable source)
Constructs a new Scanner with a Readable input as source.

Parameters:
source - The Readable to use as source.

Scanner

public Scanner(ReadableByteChannel source)
Constructs a new Scanner with a ReadableByteChannel as source. Therfore the Scanner(ReadableByteChannel, String) is called with null as charsetName.

Parameters:
source - The ReadableByteChannel to use as source.

Scanner

public 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.
It also initiates the main Buffer.

Parameters:
source - The ReadableByteChannel to use as source.
charsetName - The charsetName to be applied on the source.

Scanner

public Scanner(String source)
Constructs a new Scanner using the given String as input only.

Parameters:
source - The whole String to be used as source.
Method Detail

close

public void close()
Closes this Scanner. If an IOException occurs it is catched and is available under ioException().
After the Scanner is closed, all searches will lead to a IllegalStateException.


delimiter

public Pattern delimiter()
Returns the current delimiter.

Returns:
the current delimiter.

findInLine

public String findInLine(Pattern pattern)
                  throws NoSuchElementException
Tries to find the pattern in the current line.

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.

findInLine

public String findInLine(String pattern)
Compiles the given pattern into a Pattern and calls findInLine(Pattern) with the compiled pattern and returns whatever it returns.

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.

findWithinHorizon

public String findWithinHorizon(Pattern pattern,
                                int horizon)
                         throws IllegalArgumentException,
                                IllegalStateException
Trys to match the pattern within the given horizon.

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.

findWithinHorizon

public String findWithinHorizon(String pattern,
                                int horizon)
                         throws IllegalArgumentException,
                                IllegalStateException
Compile the pattern and call findWithinHorizon(Pattern, int).

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.

hasNext

public boolean hasNext()
                throws IllegalStateException
Checks if there is any next String using the current delimiter. Therefore the string must not be 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.

Specified by:
hasNext in interface Iterator<String>
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.

hasNext

public boolean hasNext(Pattern pattern)
                throws IllegalStateException
Searches the pattern in the next subString before the next current delimiter.

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.

hasNext

public boolean hasNext(String pattern)
                throws IllegalStateException
Compiles the pattern to a Pattern and calls hasNext(Pattern).

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(Pattern)

hasNextBigDecimal

public boolean hasNextBigDecimal()
                          throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a BigDecimal number.
BigDecimal numbers are always tryed with radix 10.

Returns:
true if the next string is a BigDecimal number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextBigDecimal()

hasNextBigInteger

public boolean hasNextBigInteger()
                          throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a BigInteger number.
Call hasNextBigInteger(int) with the current radix.

Returns:
true if the next string is a BigInteger number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextBigInteger()

hasNextBigInteger

public boolean hasNextBigInteger(int radix)
                          throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a BigInteger number.

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.

hasNextBoolean

public boolean hasNextBoolean()
                       throws IllegalStateException
Checks if the next string could be a boolean. The method handles the input not case sensitiv, so "true" and "TRUE" and even "tRuE" are true .

Returns:
Return true if the next string is a boolean.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextBoolean()

hasNextByte

public boolean hasNextByte()
                    throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a byte number.
Calls hasNextByte(int) with the current radix.

Returns:
true if the next string is a byte number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextByte()

hasNextByte

public boolean hasNextByte(int radix)
                    throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a byte number with the given radix.
To check, the private method myNextByte(int, boolean) is called, and if no error occurs the next string could be a byte.

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:
nextByte(int)

hasNextDouble

public boolean hasNextDouble()
                      throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a double number.
To check, the private method myNextDouble(boolean) is called, and if no error occurs the next string could be a double.

Returns:
true if the next string is a double number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextDouble()

hasNextFloat

public boolean hasNextFloat()
                     throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a double number. Because every float is a double this is checked.
To check, the private method myNextDouble(boolean) is called, and if no error occurs the next string could be a double.

Returns:
true if the next string is a double number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextFloat()

hasNextInt

public boolean hasNextInt()
                   throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as an int number.
To check, the private method myNextInt(int, boolean) is called, and if no error occurs the next string could be an int.

Returns:
true if the next string is an int number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextInt(int)

hasNextInt

public boolean hasNextInt(int radix)
                   throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as an int number with the given radix.
To check, the private method myNextInt(int, boolean) is called, and if no error occurs the next string could be an int.

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:
nextInt(int)

hasNextLine

public boolean hasNextLine()
                    throws IllegalStateException
Checks if there is a current line, which ends at the next line break or the end of the input.

Returns:
true if there is a current line.
Throws:
IllegalStateException - if the Scanner is closed.

hasNextLong

public boolean hasNextLong()
                    throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a long number.
To check, the private method myNextLong(int, boolean) is called, and if no error occurs the next string could be a long.

Returns:
true if the next string is a long number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextLong()

hasNextLong

public boolean hasNextLong(int radix)
                    throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a long number with the given radix.
To check, the private method myNextLong(int, boolean) is called, and if no error occurs the next string could be a long.

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:
nextLong(int)

hasNextShort

public boolean hasNextShort()
                     throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a short number with the given radix.
To check, the private method myNextShort(int, boolean) is called, and if no error occurs the next string could be a short.

Returns:
true if the next string is a short number.
Throws:
IllegalStateException - if the Scanner is closed.
See Also:
nextShort(int)

hasNextShort

public boolean hasNextShort(int radix)
                     throws IllegalStateException
Checks if the string to the next delimiter can be interpreted as a short number.
To check, the private method myNextShort(int, boolean) is called, and if no error occurs the next string could be a short.

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:
nextShort(int)

ioException

public IOException ioException()
Returns the last IOException occured.

Returns:
Returns the last IOException.

isUseLocale

public boolean isUseLocale()
Returns the current value of useLocale. This is used to tell the Scanner if it should use the Locale format or just handle numbers of the default format.

Returns:
the useLoclae.
See Also:
setUseLocale(boolean)

locale

public Locale locale()
Returns the current Locale. It is initialized with Locale.getDefault().

Returns:
Returns the current Locale.
See Also:
useLocale(Locale)

match

public MatchResult match()
Returns the last MatchResult found. This is updated after every successfully search.

Returns:
Returns the last MatchResult found.

next

public String next()
            throws NoSuchElementException,
                   IllegalStateException
Uses the current delimiter to find the next string in the buffer. If a string is found the current position is set after the delimiter, otherwise a NoSuchElementException is thrown. A successful match sets the matchResult.

Specified by:
next in interface Iterator<String>
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()

next

public String next(Pattern pattern)
            throws NoSuchElementException,
                   IllegalStateException
Tries to match the buffer with the given pattern. The current delimiter will not be changed.

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.

next

public String next(String pattern)
            throws NoSuchElementException,
                   IllegalStateException
Tries to match the buffer with the given pattern. The current delimiter will not be changed. Calls the next(Pattern) with the compiled pattern.

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(Pattern)

nextBigDecimal

public BigDecimal nextBigDecimal()
                          throws NoSuchElementException,
                                 IllegalStateException
Tries to interpret the next string as a BigDecimal value.

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.

nextBigInteger

public BigInteger nextBigInteger()
                          throws NoSuchElementException,
                                 IllegalStateException
Tries to interpret the next string as a BigInteger value. Call nextBigInteger(int) with the current radix as parameter, and return the value.

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:
nextBigInteger(int)

nextBigInteger

public BigInteger nextBigInteger(int radix)
                          throws NoSuchElementException,
                                 IllegalStateException
Tries to interpret the next string as a BigInteger value with the given radix.

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.

nextBoolean

public boolean nextBoolean()
                    throws NoSuchElementException,
                           IllegalStateException
Tries to interpret the next string to the delimiter as a boolean value, ignoring case.

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.

nextByte

public byte nextByte()
              throws NoSuchElementException,
                     IllegalStateException
Tries to interpret the next string as a byte value. Call nextByte(int) with the current radix as parameter, and return the value.

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:
nextByte(int)

nextByte

public byte nextByte(int radix)
              throws NoSuchElementException,
                     IllegalStateException
Tries to interpret the next string as a byte value with the given radix.

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.

nextDouble

public double nextDouble()
                  throws NoSuchElementException,
                         IllegalStateException
Tries to interpret the next string as a double value.

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.

nextFloat

public float nextFloat()
                throws NoSuchElementException,
                       IllegalStateException
Tries to interpret the next string as a double value, and then casts down to float.

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.

nextInt

public int nextInt()
            throws NoSuchElementException,
                   IllegalStateException
Tries to interpret the next string as an int value. Calls nextInt(int) with the current radix as parameter, and return the value.

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:
nextInt(int)

nextInt

public int nextInt(int radix)
            throws NoSuchElementException,
                   IllegalStateException
Tries to interpret the next string as an int value with the given radix.

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.

nextLine

public String nextLine()
                throws NoSuchElementException,
                       IllegalStateException
Tries to match the system line seperator, and returns the current line.

Returns:
Returns the current line.
Throws:
NoSuchElementException - If the current delimiter is not found.
IllegalStateException - If the Scanner is closed.

nextLong

public long nextLong()
              throws NoSuchElementException,
                     IllegalStateException
Tries to interpret the next string as a long value. Calls nextLong(int) with the current radix as parameter, and return the value.

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:
nextLong(int)

nextLong

public long nextLong(int radix)
              throws NoSuchElementException,
                     IllegalStateException
Tries to interpret the next string as a long value with the given radix.

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.

nextShort

public short nextShort()
                throws NoSuchElementException
Tries to interpret the next string as a short value. Calls nextShort(int) with the current radix as parameter, and return the value.

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:
nextShort(int)

nextShort

public short nextShort(int radix)
                throws NoSuchElementException
Tries to interpret the next string as a short value with the given radix.

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.

radix

public int radix()
Returns:
Returns the current radix.

remove

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

Specified by:
remove in interface Iterator<String>

setUseLocale

public void setUseLocale(boolean useLocale)
Parameters:
useLocale - the useLocale to set.

skip

public Scanner skip(Pattern pattern)
             throws NoSuchElementException
Skips the given pattern. Sets skipped true.

Parameters:
pattern - Pattern which should be skipped.
Returns:
this with the skipped buffer.
Throws:
NoSuchElementException - If the Pattern is not found.

skip

public Scanner skip(String pattern)
Skips a given pattern. Calls skip(Pattern) with the compiled pattern.

Parameters:
pattern - Pattern which should be skipped.
Returns:
this with the skipped buffer.
See Also:
skip(Pattern)

toString

public String toString()
Returns the string representation of this Scanner.

Overrides:
toString in class Object
Returns:
the String representing this Object, which may be null
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)

useDelimiter

public Scanner useDelimiter(Pattern pattern)
Sets the current pattern to the given parameter, and updates the Matcher with the new pattern.

Parameters:
pattern - The new pattern to use.
Returns:
Returns the Scanner (this) with the new pattern.

useDelimiter

public Scanner useDelimiter(String pattern)
Sets the current pattern to the given parameter. Compiles the pattern and calls useDelimiter(Pattern)

Parameters:
pattern - The new pattern to use.
Returns:
Returns the Scanner (this) with the new pattern.
See Also:
useDelimiter(Pattern)

useLocale

public Scanner useLocale(Locale locale)
Sets the current Locale to the given parameter. Formats and Symbols are also set using the new Locale.

Parameters:
locale - The new Locale to use. If it is null nothing happens.
Returns:
Returns the Scanner (this) with the new Locale.

useRadix

public Scanner useRadix(int radix)
                 throws IllegalArgumentException
Sets the current radix to the current value if the given radix is >= 2 and <= 36 otherwise an IllegalArgumentException is thrown.

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.