This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Reading console input from Java under Cygwin shell (was Re: inputstream!)


>if i write a simple java program that uses a BufferedReader reader object
>wrapped from and then try to read a line from user and then echo
>it back, cygwin for some reason already has stuff on the stream and so
>without waiting for the user to type something in the program fetches that
>and prints it out (it is usually) just a newline.  why does this happen!

The following code works on my system using JDK 1.4.0 and Windows 2000:

* * *



public class ConsoleInput {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(;
		String s = in.readLine();
		System.out.println("Echo: " + s);

* * *

There are some issues with reading console input on Win 9x systems that have
nothing to do with Cygwin.  See, e.g., Java Developer Connection Bug
#4071281 at  Are
you using a Windows 9x flavor?

Silly question:  Have you tried running it simply under DOS?

-- David Caldwell.

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]