About 50 results
Open links in new tab
  1. java.util.scanner - How can I read input from the console using the ...

    Here in this program we will take the Scanner class to achieve the task. This Scanner class comes under java.util, hence the first line of the program is import java.util.Scanner; which allows the user to …

  2. Reading a .txt file using Scanner class in Java - Stack Overflow

    I am working on a Java program that reads a text file line-by-line, each with a number, takes each number throws it into an array, then tries and use insertion sort to sort the array. I need help w...

  3. java - Take a char input from the Scanner - Stack Overflow

    Dec 19, 2012 · Scanner reader = new Scanner(System.in); char c = reader.nextChar(); This method doesn't exist. I tried taking c as a String. Yet, it would not always work in every case, since the other …

  4. java - Scanner is skipping nextLine () after using next () or nextFoo ...

    Aug 14, 2011 · That's because the Scanner.nextInt method does not read the newline character in your input created by hitting "Enter" and so the call to Scanner.nextLine returns after reading that newline. …

  5. Reading a plain text file in Java - Stack Overflow

    ASCII is a TEXT file so you would use Readers for reading. Java also supports reading from a binary file using InputStreams. If the files being read are huge then you would want to use a BufferedReader on …

  6. How to get the user input in Java? - Stack Overflow

    Mar 13, 2011 · I attempted to create a calculator, but I can not get it to work because I don't know how to get user input. How can I get the user input in Java?

  7. java - how to read int,double,and sentence of string using same …

    Oct 5, 2015 · When switching between reading tokens of input and reading a full line of input, you need to make another call to nextLine () because the Scanner object will read the rest of the line where its …

  8. How to read integer value from the standard input in Java

    Mar 24, 2010 · The question is "How to read from standard input". A console is a device typically associated to the keyboard and display from which a program is launched. You may wish to test if no …

  9. Validating input using java.util.Scanner - Stack Overflow

    I'm taking user input from System.in using a java.util.Scanner. I need to validate the input for things like: It must be a non-negative number It must be an alphabetical letter ... etc What's the b...

  10. java - Scanner doesn't read whole sentence - Stack Overflow

    Nov 7, 2017 · 16 Initialize the Scanner this way so that it delimits input using a new line character. Scanner sc = new Scanner(System.in).useDelimiter("\\n"); Refer the JavaDoc for more details Use …