当前位置: 技术问答>java相关
请问在java中有没有在dos下接受键盘输入的方法,如何使用?谢谢
来源: 互联网 发布时间:2014-12-30
本文导语: | Sorry for you, but I think it's impossible. Under DOS, there is no standard mechanism (in any language) to implement a keyboard listener. It's always a matter of waiting for an input result or a key to be pressed in a blocking method. ...
|
Sorry for you, but I think it's impossible. Under DOS, there is no standard mechanism (in any language) to implement a keyboard listener. It's always a matter of waiting for an input result or a key to be pressed in a blocking method. Of course, you can do it by trapping interrupts, but it's no more java.
Key listeners only work under AWT.
It is not possible to listen to Events on a CLI (Command Line Interface / Interpreter) like DOS or a Shell (tty or xterm). Key Events don't exist there. It is just bytes in streams.
Alas, the InputStreams DOS->Java are buffered, so you will probably have problems using InputStreams.
I think Java wasn't meant for terminal / keyboard driven programs
Key listeners only work under AWT.
It is not possible to listen to Events on a CLI (Command Line Interface / Interpreter) like DOS or a Shell (tty or xterm). Key Events don't exist there. It is just bytes in streams.
Alas, the InputStreams DOS->Java are buffered, so you will probably have problems using InputStreams.
I think Java wasn't meant for terminal / keyboard driven programs