About 63 results
Open links in new tab
  1. 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...

  2. java.util.scanner - How can I read input from the console using the ...

    There are several ways to get input from the user. 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 …

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

    May 2, 2010 · You can use java.util.Scanner : import java.util.Scanner; //... Scanner in = new Scanner(System.in); int num = in.nextInt(); It can also tokenize input with regular expression, …

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

    Dec 19, 2012 · There is no API method to get a character from the Scanner. You should get the String using scanner.next() and invoke String.charAt(0) method on the returned String. …

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

    In addition to Scanner(String) constructor, there's also Scanner(java.io.File) among others. Summary Scanner provides a rich set of features, such as hasNextXXX methods for validation.

  6. java - How to put a Scanner input into an array... for example a …

    Jul 10, 2018 · import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main (String[]args) { System.out.println("Introduce the sequence of numbers to store in …

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

    Aug 14, 2011 · I am using the Scanner methods nextInt() and nextLine() for reading input.. It looks like this: System.out.println("Enter numerical value"); int option; option = input.nextInt(); // …

  8. java - Read line with Scanner - Stack Overflow

    Dec 1, 2013 · scanner.useDelimiter(System.getProperty("line.separator")); You have to check whether there is a next token available and then read the next token. You will also need to …

  9. Multiple Scanner Inputs (Java) - Stack Overflow

    Sep 15, 2017 · You can use below function that will return you multiple inputs from scanner. public List<String> getInputs(String inputseparator) { System.out.println("You Message here"); …

  10. Scanning double with Scanner in Java from Console

    Aug 1, 2016 · I want to read a double number from standard input, but I always get this exception: java.util.InputMismatchException import java.util.Scanner; public class ScanDouble { public …