Java - Windows / linux中的控制台输出 [英] Java - Control console output in windows/linux

查看:249
本文介绍了Java - Windows / linux中的控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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( http://en.wikipedia.org/wiki/Ncurses)为此。如果您需要这样的智能,可以尝试 http://sourceforge.net/projects/javacurses/

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中的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆