我正在尝试在我的控制台应用中创建流程动画。是否有可能为此需要重写以前的行?我知道\r
,但它仅适用于当前行。
如果不可能,我怎么能实现动画效果?感谢。
我的控制台是标准的Ubuntu 12.04终端仿真器。
感谢@ MrSmith42,我做了这个简单的演示,它显示了覆盖行的方法:
public class Flush {
public static void main(String[] args) {
for(int i = 0; i < 5; i++) {
System.out.println("**********************************");
}
// ESC[5A - cursor up 5 times
// \r - cursor return to begin of line
// ESC[J - erase to end of screen
System.out.print("\033[5A\r\033[J");
for(int i = 0; i < 5; i++) {
System.out.println("##################################");
}
}
}
答案 0 :(得分:6)
这取决于你的控制台。很多consols支持vt100 commands,例如更改光标的位置或更改文本或背景的颜色。
我使用它来将我的java程序中的彩色调试输出发送到shell。
如果链接已死,请使用此谷歌搜索 https://www.google.de/search?q=vt100+comands&oq=vt100+comands