Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JBuilder cannot terminate the user input.

1 view
Skip to first unread message

Rong

unread,
Nov 3, 2005, 12:16:39 AM11/3/05
to
I define an "InputStream input", then I use "int data =input.read()" to read
from "System.in"(i.e.: keyboard). I will terminate the input if "data
== -1".

The problem is:
I use the same code on Eclipse and JBuilder. Eclispse will terminate the
user input if the user types in "CTRL-z". But JBuilder can not terminate the
user input.

The question is:
How can I stop user input from keyboard in JBuilder, using the codes I
described?

Thanks,


Kevin Dean [TeamB]

unread,
Nov 3, 2005, 9:54:49 AM11/3/05
to
Rong wrote:

JBuilder doesn't appear to pass on control characters sent to its
graphical output window. If you're using full lines of text and all lines
are guaranteed to contain at least some data, then you might want to
rewrite it in a fashion similar to this using a BufferedReader:

package keyboardinput;

import java.io.*;

public class Whatever {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;

while ((line = br.readLine()).length() != 0) {
System.out.println("Got " + line);
}
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}

--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html

Rong

unread,
Nov 4, 2005, 5:27:07 AM11/4/05
to
Thanks! Although I understand that in all GUI world, such a problem is
minor. But it does cause me a little trouble because I have to rewrite these
codes in order to make it work on JBuilder.But these codes is kind of given
to me by other people, I should not change these legacy codes in the first
place.

"Kevin Dean [TeamB]" <NkOdS...@datadevelopment.com> 写入消息新闻:xn0e9atwk6i...@www.teamb.com...

0 new messages