0
public static void main(String[] args) throws IOException{

  String msg;
  BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in));
  System.out.println("please type something now:");
  msg = userIn.readLine();
  System.out.println(msg);  

  userIn.close();
}

Works perfectly in eclipse but when I run through konsole msg is not printed.

Thanks in advance

1 Answers1

3

It is OS-dependent. In your case System.out.println is using a buffered output. Your program ends before System.out.println flushes the message to the standard output, so you don't see anything.

Try calling System.out.flush() to force it.

Related questions:

Community
  • 1
  • 1
Guido
  • 46,642
  • 28
  • 120
  • 174
  • Unfortunately this does not help, I should mention the program doesn't terminate (again only in konsole, in eclipse it is fine) – user1953102 Jan 06 '13 at 18:36