Skip to content

java.util.Scanner #243

@dthongvl

Description

@dthongvl

A simple text scanner which can parse primitive types and strings using regular expressions.

-------------- Write junit test for the following methods --------------------

  • Scanner(Readable source)
    Constructs a new Scanner that produces values scanned from the specified source.

  • Scanner(InputStream source)
    Constructs a new Scanner that produces values scanned from the specified input stream.

  • Scanner(File source)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(Path source)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(String source)
    Constructs a new Scanner that produces values scanned from the specified string.

  • Scanner(ReadableByteChannel source)
    Constructs a new Scanner that produces values scanned from the specified channel.

  • Scanner(Readable source, Pattern pattern)
    Constructs a Scanner that returns values scanned from the specified source delimited by the specified pattern.

  • Scanner(InputStream source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified input stream.

  • Scanner(File source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(File source, CharsetDecoder dec)

  • Scanner(Path source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(Path source, Charset charset)

  • Scanner(ReadableByteChannel source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified channel.

  • close()source
    Closes this scanner.

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

  • findInLine(Pattern pattern)
    Attempts to find the next occurrence of the specified pattern ignoring delimiters.

  • findWithinHorizon(String pattern, int horizon)
    Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.

  • findWithinHorizon(Pattern pattern, int horizon)
    Attempts to find the next occurrence of the specified pattern.

  • hasNext()source
    Returns true if this scanner has another token in its input.

  • hasNext(String pattern)
    Returns true if the next token matches the pattern constructed from the specified string.

  • hasNext(Pattern pattern)
    Returns true if the next complete token matches the specified pattern.

  • hasNextBigInteger()source
    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. ...

  • hasNextFloat()source
    Returns true if the next token in this scanner's input can be interpreted as a float value using the #nextFloat method.

  • hasNextInt()source
    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)
    Returns true if the next token in this scanner's input can be interpreted as an int value in the specified radix using the #nextInt method.

  • hasNextLine()source
    Returns true if there is another line in the input of this scanner.

  • hasNextLong()source
    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.

  • hasNextShort()source
    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. ...

  • ioException()source
    Returns the IOException last thrown by this Scanner's underlying Readable.

  • match()source
    Returns the match result of the last scanning operation performed by this scanner.

  • next()source
    Finds and returns the next complete token from this scanner.

  • next(String pattern)
    Returns the next token if it matches the pattern constructed from the specified string.

  • next(Pattern pattern)
    Returns the next token if it matches the specified pattern.

  • nextBoolean()source
    Scans the next token of the input into a boolean value and returns that value.

  • nextDouble()source
    Scans the next token of the input as a double.

  • nextFloat()source
    Scans the next token of the input as a float.

  • nextInt()source
    Scans the next token of the input as an int.

  • nextLine()source
    Advances this scanner past the current line and returns the input that was skipped.

  • nextLong()source
    Scans the next token of the input as a long.

  • nextShort()source
    Scans the next token of the input as a short.

  • 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.

  • 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.

------------ Build the following methods ------------------

  • Scanner(Readable source)
    Constructs a new Scanner that produces values scanned from the specified source.

  • Scanner(InputStream source)
    Constructs a new Scanner that produces values scanned from the specified input stream.

  • Scanner(File source)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(Path source)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(String source)
    Constructs a new Scanner that produces values scanned from the specified string.

  • Scanner(ReadableByteChannel source)
    Constructs a new Scanner that produces values scanned from the specified channel.

  • Scanner(Readable source, Pattern pattern)
    Constructs a Scanner that returns values scanned from the specified source delimited by the specified pattern.

  • Scanner(InputStream source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified input stream.

  • Scanner(File source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(File source, CharsetDecoder dec)

  • Scanner(Path source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified file.

  • Scanner(Path source, Charset charset)

  • Scanner(ReadableByteChannel source, String charsetName)
    Constructs a new Scanner that produces values scanned from the specified channel.

  • close()source
    Closes this scanner.

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

  • findInLine(Pattern pattern)
    Attempts to find the next occurrence of the specified pattern ignoring delimiters.

  • findWithinHorizon(String pattern, int horizon)
    Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.

  • findWithinHorizon(Pattern pattern, int horizon)
    Attempts to find the next occurrence of the specified pattern.

  • hasNext()source
    Returns true if this scanner has another token in its input.

  • hasNext(String pattern)
    Returns true if the next token matches the pattern constructed from the specified string.

  • hasNext(Pattern pattern)
    Returns true if the next complete token matches the specified pattern.

  • hasNextBigInteger()source
    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. ...

  • hasNextFloat()source
    Returns true if the next token in this scanner's input can be interpreted as a float value using the #nextFloat method.

  • hasNextInt()source
    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)
    Returns true if the next token in this scanner's input can be interpreted as an int value in the specified radix using the #nextInt method.

  • hasNextLine()source
    Returns true if there is another line in the input of this scanner.

  • hasNextLong()source
    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.

  • hasNextShort()source
    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. ...

  • ioException()source
    Returns the IOException last thrown by this Scanner's underlying Readable.

  • match()source
    Returns the match result of the last scanning operation performed by this scanner.

  • next()source
    Finds and returns the next complete token from this scanner.

  • next(String pattern)
    Returns the next token if it matches the pattern constructed from the specified string.

  • next(Pattern pattern)
    Returns the next token if it matches the specified pattern.

  • nextBoolean()source
    Scans the next token of the input into a boolean value and returns that value.

  • nextDouble()source
    Scans the next token of the input as a double.

  • nextFloat()source
    Scans the next token of the input as a float.

  • nextInt()source
    Scans the next token of the input as an int.

  • nextLine()source
    Advances this scanner past the current line and returns the input that was skipped.

  • nextLong()source
    Scans the next token of the input as a long.

  • nextShort()source
    Scans the next token of the input as a short.

  • 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.

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions