请问在java中有没有在dos下接受键盘输入的方法,如何使用?谢谢

petertangh 2001-04-22 11:34:00
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
v不吃v你 2001-04-22
  • 打赏
  • 举报
回复
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

Zephyr_Boy 2001-04-22
  • 打赏
  • 举报
回复
看书先,再来问

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧