Questions tagged [system.in]

Predefined stream object attached to the standard input in Java console applications.

It's a static variable in Java's System class. This tag is intended for questions about Java applications that read from the standard input.

177 questions
0
votes
1 answer

java won't break up a user input with multiple double and char variables using Scanner and System.in

I want the user to input a math equation using one of these variables: *, /, +, - Input Examples (with no spaces) : 2*2, 35.7/3, 4.5+5.5 Then I want to break the first number, char variable, and second number apart and store them into…
1bntcr001
  • 1
  • 2
0
votes
3 answers

Using BufferReader to get input from User

So when I run my program's main method it prints: Enter number of test cases: 1 Enter string 1 Enter string 2 rat apple cat ear cat apple rat For some reason it prints Enter string 1 and Enter string 2 before I even put in anything for String…
Beginner
  • 143
  • 4
  • 11
0
votes
2 answers

How to simulate user input for Scanner?

I have a class in which the user interacts on a terminal window and types in certain options, based on those options it makes a switch and uses certain methods; I need to use a scanner to detect user input. I tried for a few days to make a test…
4673_j
  • 389
  • 1
  • 4
  • 16
0
votes
4 answers

Keep console input active without main thread? (Java)

I am writing a server in Java, which is multithreaded. I have three main active threads that I build and start from my main method: public class Run{ public static void main(String[] args){ try{ /* * Definition…
Code Doggo
  • 1,700
  • 4
  • 25
  • 51
0
votes
3 answers

Trying to Understand Where My Loop Goes Wrong

So here is my task: A postal company for a package charges $15 for the first pound or a fraction thereof and $10 per pound for anything over one pound. Write a program that prints the charge of a package. Variables: weight First…
0
votes
1 answer

Calling next() on a Scanner initialized by a closed stream doesn't throw IllegalStateException

The Scanner documentation says that when one calls next() on a closed stream then these two exceptions may be thrown: NoSuchElementException - if no more tokens are available IllegalStateException - if this scanner is closed Furthermore hasNext()…
Master_ex
  • 779
  • 7
  • 12
0
votes
1 answer

java SWT to connect to remote server using Jcraft JSch

I am working on on a tool to connect to a remote server using jcraft.JSch (ssh to Unix server) and return the output and display its output (something like putty, but iam not keen on Plink or any third party thing). The code works fine when channel…
0
votes
1 answer

I'm trying to run console input in a thread in Java but my program is getting hungup on the readLine() method

I'm creating this program to test getting user input in a thread for a chat server program. This program stops on read = into.readLine();. Why is that and what's happening? Here is the code: import java.io.*; import java.net.*; public…
Mason0958
  • 39
  • 10
0
votes
0 answers

Runtime error in java code

I'm creating a program for an assignment which takes an input from System.in in the following format: Inky Pinky Blinky Clyde Luigi Mario Bowser 0 2 1 2 5 6 3 5 2 4 4 5 2 3 1 4 closefriends 1 2 4 where the first line is persons, the numbers are…
0
votes
1 answer

Jsch - System in, out and er without redirection?

I am in the process of playing with Jcrafts JSch Library to build a Terminal application. It works fine and does what it says, however I have to redirect System out, in and err to various swing components for it work in a GUI application. I have…
Yonkee
  • 1,221
  • 3
  • 21
  • 43
0
votes
1 answer

System.in, System.out from strings

I have to test a main method, I want to send stuff to System.in and then see what comes out of System.out. I do it like this: public class Check3_1 { public static void main(String[] args) throws UnsupportedEncodingException { …
mist
  • 1,835
  • 2
  • 19
  • 33
0
votes
1 answer

System.in.read() returns null causing NullPointerException (cannot find cause)

I have a program and the CMD always returns: …
Harry Saliba
  • 116
  • 1
  • 11
0
votes
1 answer

Java use system read in switch statements

I am trying the following switch statements using System.in.read(): char ch1, ch2; ch1 = (char) System.in.read(); switch(ch1) { case 'A': System.out.println("This A is part of outer switch."); ch2 = (char)…
daiyue
  • 6,164
  • 16
  • 67
  • 117
0
votes
1 answer

Compiler presenting errors although Scanner is imported?

import java.util.Scanner; public class System { public static void main(String[]args){ Scanner scan = new Scanner(System.in); String cName, cContact, cAddress, cIC, cDob, cGender; int i; } } Sorry if this was a…
Damian A.
  • 1
  • 1
0
votes
1 answer

Making a coinflip game using objects and methods java?

I'm trying to make a coin flip game in java. I'm relatively new to the language and the only other language I knew was Javascript, so I'm still learning. I've already made one before using just one class and putting all the code inside, but I'm now…
Bob Mc Muffins.
  • 37
  • 2
  • 11