简体   繁体   English

使用Java在控制台中显示动态输出

[英]Showing dynamic output in console using Java

When using curl , I've noticed that it outputs to the terminal text that can be then later replaced and updated. 当使用curl ,我注意到它输出到终端文本,然后可以在以后替换和更新。 This 'dynamic' text output is what I'd like to do. 这个“动态”文本输出是我想要做的。

Specifically: 特别:

An execution like: curl http://raw.github.com/someGZippedPackage | gunzip 执行如: curl http://raw.github.com/someGZippedPackage | gunzip curl http://raw.github.com/someGZippedPackage | gunzip shows the percentage completion and a completion bar in the terminal . curl http://raw.github.com/someGZippedPackage | gunzip显示完成百分比和终端中的完成条。

Are there libraries that provide this functionality? 是否有提供此功能的库?

I can use any object-oriented programming language. 我可以使用任何面向对象的编程语言。

Preferably built for either Java or Node.js. 最好为Java或Node.js构建。

You can probably hack something together using the javacurses library, available here. 你可以使用这里提供的javacurses库来一起破解。 http://sourceforge.net/projects/javacurses/ http://sourceforge.net/projects/javacurses/

If you haven't used curses before, it can be used to provide an interface similar to the one you might see in the BIOS menu. 如果您之前没有使用过curses,它可以用来提供类似于BIOS菜单中看到的界面。 It is the standard way to program menu driven text interfaces, and works for other applications as well. 它是编程菜单驱动的文本界面的标准方法,也适用于其他应用程序。

Here's a solid intro to programming with curses, although actually written for the c library. 这是使用curses编程的可靠介绍,尽管实际上是为c库编写的。 http://invisible-island.net/ncurses/ncurses-intro.html http://invisible-island.net/ncurses/ncurses-intro.html

Basically move a "cursor" around with move and add characters with addch , then refresh the screen. 基本上移动“光标”周围的move ,并加入字符addch ,然后刷新屏幕。

Godspeed. 一帆风顺。

This is called a progress bar , which can be generated without curses, by using backspace and carriage return characters. 这称为进度条 ,可以使用退格和回车字符生成而无需curses。

This makes your question a duplicate of Command line progress bar in Java 这使您的问题与Java中命令行进度条重复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM