Java: Updating text in the command-line without a new line(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:在命令行中更新文本而无需换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java:在命令行中更新文本而无需换行


基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 大摇大摆的枚举 2022-01-01