Top "Java.util.scanner" questions

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

Weird behaviour with Scanner#nextFloat

Running the following in Eclipse initially caused Scanner to not recognize carriage returns in the console effectively blocking further input: …

java java.util.scanner
I keep getting "Exception in thread "main" java.util.NoSuchElementException"

So I'm trying to make a simple program in Java that reads a text file (from a command line argument) …

java java.util.scanner nosuchelementexception
Explain this line written in JAVA

In HACKERRANK this line of code occurs very frequently. I think this is to skip whitespaces but what does that "\…

java java.util.scanner
How can I get this switch statement to work using a scanner?

I'm trying to write a program that will switch any letter of the alphabet (upper or lower cases) into the …

java string switch-statement java.util.scanner phonetics
How to interrupt java.util.Scanner nextLine call

I am using a multi threaded environment were one Thread is constantly listening for user input by repeatedly calling scanner.…

java command-line interrupt java.util.scanner
How to use Scanner to read silently from STDIN in Java?

I want to make a Java program that reads a Password from STDIN silently. I mean, without outputting any pressed …

java stdin java.util.scanner
Asking for input after catching an exception

I want the user to enter a number which is scanned by the following code: scanner.nextInt(); If a user …

java java.util.scanner numberformatexception inputmismatchexception
Tokenising a String containing empty tokens

I have a seemingly simple problem of splitting a comma separated String into tokens, whereby the output should include empty …

java string java.util.scanner stringtokenizer string-split
How to use the same Scanner across multiple classes in Java

I have a program that uses multiple classes, I want the other classes to be able to access the same …

java class java.util.scanner