Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "David P. Caldwell" To: , Subject: Reading console input from Java under Cygwin shell (was Re: inputstream!) Date: Mon, 25 Feb 2002 11:26:38 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 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/