Reading console input from Java under Cygwin shell (was Re: inputstream!)
David P. Caldwell
inonit@inonit.com
Mon Feb 25 09:26:00 GMT 2002
Pramod:
>if i write a simple java program that uses a BufferedReader reader object
>wrapped from System.in 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:
* * *
package test.io;
import java.io.*;
public class ConsoleInput {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
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
http://developer.java.sun.com/developer/bugParade/bugs/4071281.html. Are
you using a Windows 9x flavor?
Silly question: Have you tried running it simply under DOS?
-- David Caldwell.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list