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

  • SEARCH
  • Home
  • 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 8387701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:17:10+00:00 2026-06-09T18:17:10+00:00

i wanted to read the output-stream of a c-Application in my Java program. iremoted

  • 0

i wanted to read the output-stream of a c-Application in my Java program. iremoted (available here: Link) is a C-Application that puts out seperate lines like "0x19 pressed" if a button on my Apple Remote is pressed. If i start the iremoted program everything is doing well and these separate lines are shown on my screen everytime I pressed a button.
Now I wanted to read the output-stream of the c-application in my Java application to process inputs of the Apple Remote in Java projects.
Unfortunately i don’t know why no input is regocnized?

I tried it with a simple HelloWorld.c program and my program responded as intended in this case (prints out HelloWorld).

Why doensn’t it work with the iremoted program?

public class RemoteListener {


public void listen(String command) throws IOException {
    
    String line;
    Process process = null;
    try {
        process = Runtime.getRuntime().exec(command);
    } catch (Exception e) {
        System.err.println("Could not execute program. Shut down now.");
        System.exit(-1);
    }
    
    Reader inStreamReader = new InputStreamReader(process.getInputStream());
    BufferedReader in = new BufferedReader(inStreamReader);
   
    System.out.println("Stream started");
    while((line = in.readLine()) != null) {
        System.out.println(line);
    }
    in.close();
    System.out.println("Stream Closed");
}




public static void main(String args[]) {
    RemoteListener r = new RemoteListener();
    try {
        r.listen("./iremoted"); /* not working... why?*/
        // r.listen("./HelloWorld"); /* working fine */
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}
  • 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-09T18:17:12+00:00Added an answer on June 9, 2026 at 6:17 pm

    stdout is buffered and it’s not automatically flushed if you are not writing to screen. Add:

    fflush(stdout);
    

    after:

    printf("%#lx %s\n", (UInt32)event.elementCookie,
        (event.value == 0) ? "depressed" : "pressed");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've to read program log file and to do that I wanted to use
I've read about Single-Page Applications recently and wanted to try one out. After watching
I need to un-read characters from an InputStreamReader . For that purpose I wanted
Im still teaching myself Java so I wanted to try to read a text
I wanted to read output of a command in an array: Something like: (reformatted
I've read through a few questions that address something similar, but wanted to ask
I am a novice when it comes to java. I wanted to read the
I wanted to read version information of my application from the plit file. For
I am new to Python and wanted to read a file, which has even
Initial Question Yesterday i read about ECMAScript 5 Object.create() And I wanted to start

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.