Lorenz
Lorenz

Reputation: 39

Java - "Live" output from Systemcommand

I've made a little GUI for youtube-dl, but for this project, I nedd kind of a "live" output from a system command. I already tried this, but this only displays the output when the process has finished. I need something which displays the progress of my download continously (youtube-dl is just a command line tool, so it needs to refresh about every second).

How do i do that?

Upvotes: 1

Views: 370

Answers (2)

JonasP
JonasP

Reputation: 51

I would suggest starting a new Thread by hitting the Download-Button by using:

Runner = new Thread(this, "ExternalProcessTest");
Runner.start();

in the Listener.

Additional Infos about GUI-Threads could be found here: non-blocking Thread

Some additional approaches for progress bars in a console: progress-bar console

Upvotes: 1

Lorenz
Lorenz

Reputation: 39

After a bit of searching, I found the answer:

My Problem was, that the Terminal, where "System.out.println()" prints its output to, didn't refresh. It just wrote the outout after the Process finished, but because I'm writing a Download client, you have to see the progress of your Download. So I've done it this way:

Get output of terminal command using Java

Upvotes: 0

Related Questions