Scanner (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Closeable, AutoCloseable, Iterator<String>
-
Constructor Summary
Constructors
Constructs a new
Scannerthat produces values scanned from the specified file.Constructs a new
Scannerthat produces values scanned from the specified file.Constructs a new
Scannerthat produces values scanned from the specified file.Constructs a new
Scannerthat produces values scanned from the specified input stream.Constructs a new
Scannerthat produces values scanned from the specified input stream.Constructs a new
Scannerthat produces values scanned from the specified input stream.Constructs a new
Scannerthat produces values scanned from the specified source.Constructs a new
Scannerthat produces values scanned from the specified string.Constructs a new
Scannerthat produces values scanned from the specified channel.Constructs a new
Scannerthat produces values scanned from the specified channel.Constructs a new
Scannerthat produces values scanned from the specified channel.Constructs a new
Scannerthat produces values scanned from the specified file.Constructs a new
Scannerthat produces values scanned from the specified file.Constructs a new
Scannerthat produces values scanned from the specified file. -
Method Summary
voidclose()Returns the
PatternthisScanneris currently using to match delimiters.Returns a stream of match results that match the provided pattern string.
Returns a stream of match results from this scanner.
Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.
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.
Attempts to find the next occurrence of the specified pattern.
booleanhasNext()Returns true if this scanner has another token in its input.
booleanReturns true if the next token matches the pattern constructed from the specified string.
booleanReturns true if the next complete token matches the specified pattern.
booleanReturns true if the next token in this scanner's input can be interpreted as a
BigDecimalusing thenextBigDecimal()method.booleanReturns true if the next token in this scanner's input can be interpreted as a
BigIntegerin the default radix using thenextBigInteger()method.booleanhasNextBigInteger(int radix) Returns true if the next token in this scanner's input can be interpreted as a
BigIntegerin the specified radix using thenextBigInteger()method.booleanReturns true if the next token in this scanner's input can be interpreted as a boolean value using a case insensitive pattern created from the string "true|false".
booleanReturns true if the next token in this scanner's input can be interpreted as a byte value in the default radix using the
nextByte()method.booleanhasNextByte(int radix) Returns true if the next token in this scanner's input can be interpreted as a byte value in the specified radix using the
nextByte()method.booleanReturns true if the next token in this scanner's input can be interpreted as a double value using the
nextDouble()method.booleanReturns true if the next token in this scanner's input can be interpreted as a float value using the
nextFloat()method.booleanReturns 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.booleanhasNextInt(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.booleanReturns true if there is another line in the input of this scanner.
booleanReturns 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.booleanhasNextLong(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.booleanReturns 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.booleanhasNextShort(int radix) Returns true if the next token in this scanner's input can be interpreted as a short value in the specified radix using the
nextShort()method.Returns the
IOExceptionlast thrown by thisScanner's underlyingReadable.locale()Returns this scanner's locale.
match()Returns the match result of the last scanning operation performed by this scanner.
next()Finds and returns the next complete token from this scanner.
Returns the next token if it matches the pattern constructed from the specified string.
Returns the next token if it matches the specified pattern.
Scans the next token of the input as a
BigDecimal.Scans the next token of the input as a
BigInteger.nextBigInteger(int radix) Scans the next token of the input as a
BigInteger.booleanScans the next token of the input into a boolean value and returns that value.
bytenextByte()Scans the next token of the input as a
byte.bytenextByte(int radix) Scans the next token of the input as a
byte.doubleScans the next token of the input as a
double.floatScans the next token of the input as a
float.intnextInt()Scans the next token of the input as an
int.intnextInt(int radix) Scans the next token of the input as an
int.nextLine()Advances this scanner past the current line and returns the input that was skipped.
longnextLong()Scans the next token of the input as a
long.longnextLong(int radix) Scans the next token of the input as a
long.shortScans the next token of the input as a
short.shortnextShort(int radix) Scans the next token of the input as a
short.intradix()Returns this scanner's default radix.
voidremove()The remove operation is not supported by this implementation of
Iterator.reset()Skips input that matches a pattern constructed from the specified string.
Skips input that matches the specified pattern, ignoring delimiters.
tokens()Returns a stream of delimiter-separated tokens from this scanner.
toString()Returns the string representation of this
Scanner.Sets this scanner's delimiting pattern to a pattern constructed from the specified
String.Sets this scanner's delimiting pattern to the specified pattern.
Sets this scanner's locale to the specified locale.
useRadix(int radix) Sets this scanner's default radix to the specified radix.
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
booleanIndicates whether some other object is "equal to" this one.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.intReturns a hash code value for this object.
final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface Iterator
default voidPerforms the given action for each remaining element until all elements have been processed or the action throws an exception.
-
Constructor Details
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
Scanner
-
-
Method Details
-
close
-
ioException
-
delimiter
-
useDelimiter
-
useDelimiter
-
locale
-
useLocale
-
radix
-
useRadix
-
match
-
toString
-
hasNext
-
next
-
remove
-
hasNext
-
next
-
hasNext
-
next
-
hasNextLine
-
nextLine
-
findInLine
-
findInLine
-
findWithinHorizon
-
findWithinHorizon
-
skip
-
skip
-
hasNextBoolean
-
nextBoolean
-
hasNextByte
-
hasNextByte
-
nextByte
-
nextByte
-
hasNextShort
-
hasNextShort
-
nextShort
-
nextShort
-
hasNextInt
-
hasNextInt
-
nextInt
-
nextInt
-
hasNextLong
-
hasNextLong
-
nextLong
-
nextLong
-
hasNextFloat
-
nextFloat
-
hasNextDouble
-
nextDouble
-
hasNextBigInteger
-
hasNextBigInteger
-
nextBigInteger
-
nextBigInteger
-
hasNextBigDecimal
-
nextBigDecimal
-
reset
-
tokens
-
findAll
-
findAll
-