Java:在命令行中更新文本而没有新行 [英] Java: Updating text in the command-line without a new line
本文介绍了Java:在命令行中更新文本而没有新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为命令行Java程序添加进度指示器。
例如,如果我使用wget, p>
71%[========================= ==> ] 358,756,352 51.2M / s eta 3s
可以有一个进度指示器更新而不添加
解决方案
首先,你写的,不要使用writeln()。使用write()。第二,你可以使用\r来返回,而不使用\\\
这是一个新行。回车应该把你放回行的开头。
I'd like to add a progress indicator to a command-line Java program.
For example, if I'm using wget, it shows:
71% [===========================> ] 358,756,352 51.2M/s eta 3s
Is it possible to have a progress indicator that updates without adding a new line to the bottom?
Thanks.
解决方案
First when you write, don't use writeln(). Use write(). Second, you can use a "\r" to Carriage Return without using \n which is a New line. The carriage return should put you back at the beginning of the line.
这篇关于Java:在命令行中更新文本而没有新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文