Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9317113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:47:45+00:00 2026-06-19T02:47:45+00:00

For some terminal commands, they repeatedly output. For example, for something that’s generating a

  • 0

For some terminal commands, they repeatedly output. For example, for something that’s generating a file, it may output the percent that it is complete.

I know how to call terminal commands in Java using

Process p = Runtime.getRuntim().exec("command goes here");

but that doesn’t give me a live feed of the current output of the command. How can I do this so that I can do a System.out.println() every 100 milliseconds, for example, to see what the most recent output of the process was.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:47:47+00:00Added an answer on June 19, 2026 at 2:47 am

    You need to read InputStream from the process, here is an example:

    Edit I modified the code as suggested here to receive the errStream with the stdInput

    ProcessBuilder builder = new ProcessBuilder("command goes here");
    builder.redirectErrorStream(true);
    Process process = builder.start();
    InputStream is = process.getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    
    String line = null;
    while ((line = reader.readLine()) != null) {
       System.out.println(line);
    }
    

    For debugging purpose, you can read the input as bytes instead of using readLine just in case that the process does not terminate messages with newLine

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Cocoa app that has to execute some terminal commands . One
What I'm trying to do is simply have the output of some terminal commands
I'm trying to write Java code that executes some terminal commands. The code should
Does the latest version of MacRuby support static compilation? Here's some terminal output from
when compiling some projects on linux terminal, I get usually a long output consisting
I have a file stored in the terminal server and there are some inforation
I'm reading Why's guide, and trying some of the commands in the ruby terminal
On my machine, I have some software which takes commands in the terminal and
I want to execute some terminal commands from my AppleScript. I am executing this
Let's say I have some terminal commands like: sudo mycommand1 mycommand2 #..... What should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.