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 993335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:24:24+00:00 2026-05-16T06:24:24+00:00

In the following code, am executing a java program Newsworthy_CA. The program prints the

  • 0

In the following code, am executing a java program Newsworthy_CA.
The program prints the output of the Newsworthy_CA program but the difficulty I face is it prints the whole output only after the complete execution of Newsworthy_CA program.
But I need the output to be printed simultaneously as the program is being executed.

Also, I need child.waitFor() for stopping the program from continuation if any error occurs.

Please suggest me some good idea for my requirement. Thanks in advance.

Note: Am a beginner in Java

    command = "java Newsworthy_CA";
    Process child4 = Runtime.getRuntime().exec(command);
    try{
    c= child4.waitFor();
    } catch (Exception ex){ex.printStackTrace();}
    if (c!=0){
    System.out.println("Error Occurred in ("+command+"): "+c);
    InputStream in4 = child4.getErrorStream();
    while ((c = in4.read()) != -1) {
        System.out.print((char)c);
    }
    in4.close();
    return;
    }
    InputStream in4 = child4.getInputStream();
    while ((c = in4.read()) != -1) {
    System.out.print((char)c);
    }
    in4.close();
  • 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-05-16T06:24:25+00:00Added an answer on May 16, 2026 at 6:24 am

    If you want to see output from the external program as it executes, don’t you want to have the the InputStream block moved up above the waitFor()?

    As your code reads, you very clearly say to execute and wait for completion before doing anything… including printing the external program’s output (the InputStream block).

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

Sidebar

Related Questions

The following code is executing perfectly but there is a mySQL error somewhere that
I am getting Incorrect syntax near the keyword 'select' after executing the following code.
I am creating a logger in java by executing the following code: private static
I am executing the following code to install SQL Server 2012 in silent mode.
I am executing the following code: def takeN(s : String, n : Int): String
When executing the following code: OpenFileDialog dialog = new OpenFileDialog(); DialogResult result = dialog.ShowDialog();
If I try executing the following code f = file('test','rb') fout = file('test.out','wb') for
I have a problem with the following code, when executing the call to cublasSrotg
I'm trying to play an mp3 audio file on iPhone executing the following code:
I'm finding it difficult to get started in Objective-C. I'm executing the following code

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.