问题描述
Java是否支持在输出到控制台时控制光标?例如,我想在执行System.out.print()之前设置字符位置,可能还有颜色。想想像top这样的应用程序写入控制台的方式。谢谢!
Does Java support controlling the cursor when outputting to a console? For example, I'd like to set the character position, and possibly color, before doing a System.out.print(). Think of the way an application like top writes to the console. Thanks!
推荐答案
您通常不使用system.out来执行这些操作。 * nix中的大多数应用程序都使用NCURSES( 。
You usually do not use system.out to do these things. most applications in *nix use NCURSES (http://en.wikipedia.org/wiki/Ncurses) for this. You can try http://sourceforge.net/projects/javacurses/ if you need something this smart.
但是,如果你想删除你想要的东西,你总是可以输出退格(\ b)字符,并希望获得最好的
However, you can always sysout backspace (\b) characters if you want to delete what you wanted, and hope for the best
这篇关于Java - Windows / linux中的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!