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
3 answers

Input of "System.in.read()" in Eclipse

When you read from the standard input in Eclipse, where does that input come from?
Johnny
  • 613
  • 3
  • 8
  • 21
0
votes
1 answer

Java redirecting System.in - InputStream.read called but nothing "returned"

So I'm trying to redirect a textbox to System.in. I've seen this thread Redirect System.in to swing component , and seem to have everything working: private class SystemIn extends InputStream { @Override public int read() { int x =…
Raekye
  • 4,795
  • 8
  • 45
  • 72
0
votes
1 answer

How do I replace typed text in a console when something is printed there?

I am reading and writing from console created by running my application from a batch file. I am creating a small servlet and I am running into the problem that while I am typing, things are printed (such as things like clients connecting or…
0
votes
1 answer

java: console application main thread spawns a key listener thread

I wrote a tool, which is performing some steps 1..n Some of the steps require user interaction (reading from System.in) Other steps loop until some condition is fulfilled or the user pressed some key (When the user pressed the key the loop should…
radio
  • 787
  • 1
  • 8
  • 20
-1
votes
1 answer

Edit the method for using System.in and System.out

I have this methods OutputStream os = new FileOutputStream("out.txt"); InputStream is = new FileInputStream("out.txt"); Transit.outputTransport(Parking, os); System.out.println(Parking.toString()); Transport forOut =…
-1
votes
3 answers

Why does the string inside println method show twice?

In the following code why does the string inside println method shows twice.What should I do to show the message once per iteration package practicejava; public class Query { public static void main(String[] args) throws java.io.IOException { …
Tushar Mia
  • 245
  • 2
  • 6
-1
votes
2 answers

Read/Catch stdout message in another application

I have an application A which writes a stdout message. Now i will build a second application B which reads the stdout from A. I don't want create a file, the message will be write in the console and should be read from console. I know, that i have…
HaDo
  • 1
-1
votes
2 answers

Java String not storing same value when assigned to Scanner NextLine()

I have come across a problem with the console handler of my code. I don't know if reading in after assigning it to s.nextLine(); discards the current value of in. Not sure if anything else could affect the String from being read correctly in one…
-1
votes
2 answers

is there any alternative way to provide input to readline apart from console?

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter your name: "); String name = reader.readLine(); can i provide input from java code instead of console ?
Yogesh Borkhade
  • 578
  • 4
  • 9
-1
votes
2 answers

I'm trying to take an input using Scanner(System.in) but it's not letting me. Help!

So I'm trying to take an input from a user using Scanner(System.in) but when i try to type something into the console it won't let me. Can anyone help? Function.show(); Scanner input = new Scanner(System.in); if (input.equals("a")) { …
bananamana
  • 467
  • 1
  • 9
  • 19
-1
votes
4 answers

Cant read last line of my integer input

public static void main(String[] arg) { System.out.println("Enter the pairs: "); Scanner kbd = new Scanner(System.in); while(kbd.hasNextLine() ) { int input1 = kbd.nextInt(); int input2 = kbd.nextInt(); …
-1
votes
2 answers

Trying to loop any users choice int that is either not 1-3 and/or at the end of the process of their selection

I am not sure if I am using public static int correctly as well. All in all I feel like this code is a giant mess where I just kept adding more and more to it that I probably don't need, but this point I still cant quite figure out how to get it to…
-1
votes
1 answer

basic reading input from user in java

I want to read a character and store it into the char[] array and here is my method called getaline public static int getaline(char message[], int maxlength) { int index = 0; while (message[index] != '\n') { message[index] =…
cohsta
  • 169
  • 1
  • 2
  • 12
-1
votes
1 answer

Java. System.in.read() and "\n" in console

Im currently creating a java program which should read the console and print it out, once again. The code looks like this: import java.io.IOException; public class printer { public static void main(String[] args){ int i; try { while…
user3712130
  • 77
  • 1
  • 3
  • 7
-1
votes
1 answer

Java System.in in an if else statement?

I want to be able to implement the System.in input into an if else statement, but have not quite found how, I'm a beginner with java and i'm creating a basic calculator. //if input = fMultiply then multiply if () { answer = fnum *…
1 2 3
11
12