java.util.scanner Questions
3
The following code gives same output with or without the close() call on the Scanner.
import java.util.Scanner;
class CheckPassFail {
// Write a program called CheckPassFail which prints "P...
Brachial asked 11/3, 2015 at 0:23
5
I'm trying to read a one line file character by character using java.util.Scanner. However I'm getting this exception":
Exception in thread "main" java.util.InputMismatchException: For input strin...
Violaviolable asked 11/1, 2010 at 0:12
4
Solved
I was looking through O'Reillys Java Cookbook (2ed) for some good stuff and found Scanner.create() method about 10 times. But there's no such in the API or class declaration\implementation. Ex: Pag...
Goshen asked 26/1, 2012 at 21:46
6
Solved
In my current program one method asks the user to enter the description of a product as a String input. However, when I later attempt to print out this information, only the first word of the Strin...
Theolatheologian asked 30/10, 2011 at 17:49
7
Solved
I'm reading 2 csv files: store_inventory & new_acquisitions.
I want to be able to compare the store_inventory csv file with new_acquisitions.
1) If the item names match just update the quantit...
Poseur asked 6/6, 2010 at 1:53
13
Solved
Input Format
Read some unknown n lines of input from stdin(System.in) until you reach EOF; each line of input contains a non-empty String.
Output Format
For each line, print the line number, fol...
Menchaca asked 18/12, 2015 at 11:51
5
I've been having trouble using java's Scanner class. I can get it to read my input just fine, but the problem is when I want to output something. Given multiple lines of input, I want to print just...
Wamsley asked 22/3, 2012 at 5:32
4
Solved
I have a program that uses multiple classes, I want the other classes to be able to access the same scanner that I have declared in the main class.
I assume it would be done using some sort of get ...
Ebneter asked 28/3, 2015 at 22:0
3
Solved
I am using Scanner to scan a .txt document in Java. However, when I open the .txt document in Eclipse, I notice some characters are not being recognized, and they are replaced with something that l...
Hedve asked 30/6, 2013 at 0:0
6
Solved
I'm new to using Java, but I have some previous experience with C#. The issue I'm having comes with reading user input from console.
I'm running into the "java.util.NoSuchElementException"...
Nerynesbit asked 24/10, 2012 at 2:4
25
Solved
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(); // Read numeric...
Fibrovascular asked 27/10, 2012 at 16:37
4
Solved
My professor tends to do the following to get a number from the user:
Scanner scanner = new Scanner(System.in);
Integer.parseInt(scanner.nextLine());
What are the benefits as opposed to simply d...
Pricket asked 27/10, 2014 at 11:24
10
Solved
I am very new to Java but am working through the book Java: How to program (9th ed.) and have reached an example where for the life of me I cannot figure out what the problem is.
Here is a (slight...
Dierolf asked 5/12, 2012 at 17:47
5
Solved
Scanner input = new Scanner(System.in);
Could you give me a detailed explanation on what the code above is doing step by step? I don't really understand how it works and how it links to me later ...
Austerity asked 3/6, 2015 at 6:50
10
Solved
I'm writing a program in Java and one of the things that I need to do is to create a set of every valid location for a shortest path problem. The locations are defined in a .txt file that follows a...
Crossindex asked 30/11, 2011 at 18:5
17
Solved
How could I read input from the console using the Scanner class? Something like this:
System.out.println("Enter your username: ");
Scanner = input(); // Or something like this, I don't know the co...
Snuffy asked 8/8, 2012 at 19:13
9
Solved
I am trying to read some words from an online text file.
I tried doing something like this
File file = new File("http://www.puzzlers.org/pub/wordlists/pocket.txt");
Scanner scan = new Scanner(fil...
Banks asked 6/6, 2011 at 23:55
9
Solved
What is the best way to extract the integer part of a string like
Hello123
How do you get the 123 part. You can sort of hack it using Java's Scanner, is there a better way?
Councillor asked 14/12, 2009 at 20:23
7
Solved
I got an run time exception in my program while I am reading a file through a Scanner.
java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at Day1.Re...
Rhomboid asked 26/8, 2011 at 18:35
8
Solved
I am creating a small algorithm and this is a part of it.
If the user enters non integer values, I want to output a message and let the user enter a number again:
boolean wenttocatch;
do
{
tr...
Fortyniner asked 15/9, 2015 at 18:14
13
Solved
Scanner scan = new Scanner(System.in);
double numbers = scan.nextDouble();
double[] avg =..????
Ornstead asked 8/5, 2010 at 19:34
7
Solved
I a newbie to java so please don't rate down if this sounds absolute dumb to you
ok how do I enter this using a single scanner object
5
hello how do you do
welcome to my world
6 7
fo...
Hypanthium asked 8/4, 2014 at 7:0
9
Solved
how to take user input in Array using Java?
i.e we are not initializing it by ourself in our program but the user is going to give its value..
please guide!!
Capon asked 12/4, 2010 at 14:19
21
I am working on a program and I want to allow a user to enter multiple integers when prompted. I have tried to use a scanner but I found that it only stores the first integer entered by the user. F...
Clef asked 6/5, 2014 at 23:52
24
I'm writing a program which allows the user to input his data then outputs it. Its 3/4 correct but when it arrives at outputting the address it only prints a word lets say only 'Archbishop' from 'A...
Whizbang asked 30/10, 2010 at 13:35
1 Next >
© 2022 - 2025 — McMap. All rights reserved.