1

我正在用java编写一个shell程序,它提示我的用户输入输入(即“提示:”)

然而,监控活动的单独线程也会打印到 shell,例如:“客户端已连接!”

关于如何使它成为一个更加用户友好的环境的任何想法/提示,其中用户在返回之前的输入不会被系统消息中断,但仍然允许显示消息?

4

1 回答 1

0

Typical console applications print information to screen sequentially. Programs the print information while waiting response to user are interactive program that usually control where and how do they print information. As an example you can see how top works on Unix.

There is a way to implement such kind of applications in java. You have to implement escape sequences for each supported terminal, so that you can control where and how to print each character. Fortunately there is such library that already does this.

See for example this discussion: What's a good Java, curses-like, library for terminal applications?

于 2012-10-14T18:05:39.273 回答