Java:在命令行中更新文本而无需换行 [英] Java: Updating text in the command-line without a new line

查看:23
本文介绍了Java:在命令行中更新文本而无需换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在命令行 Java 程序中添加进度指示器.

I'd like to add a progress indicator to a command-line Java program.

例如,如果我使用 wget,它会显示:

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?

谢谢.

推荐答案

首先写的时候不要使用writeln().使用写().其次,您可以使用 "来回车而不使用 ,这是一个换行符.回车应该让你回到行首.

First when you write, don't use writeln(). Use write(). Second, you can use a " " to Carriage Return without using which is a New line. The carriage return should put you back at the beginning of the line.

这篇关于Java:在命令行中更新文本而无需换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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