I have an external console app I am trying to read from. My code starts the .exe process. I am using a buffered reader, .getinputstream, and then .readLine. I then print the Line to the console. I have some unexpected results doing this. After starting the Process i do not see it in my task manager processes. I used isAlive() to verify that the process has actually started and, it returns true. If I run the process in a separate java file, the process starts correctly. I can see it in task manager processes.
2)When running the code, I get intermittent results. Most of the time .println(Line) does not print anything(in the eclipse). I have seen the println work on this code a couple of times but, it is not constantly working.
I have only been writing in java for about two weeks, so my understanding of how most of these functions work is remedial. I feel like this is either a timing issue between the .exe and my code or i am using something for the wrong purpose as well as making some things harder than they have to be. Any help would be greatly appreciated.
Windows 10, Eclipse IDE
!EXPECTED RESULTS!
STALL WARNING = 0 // APP SENDS SIGNAL THAT STALL IS OFF
STALL WARNING = 1 // APP SENDS SIGNAL THAT STALL IS ON ECT....
STALL WARNING = 0
STALL WARNING = 1
!ACTUAL RESULTS!
.... //ELAPSED TIME 5-20 MINUTES NO RESULTS
STALL WARNING = 0
.... //ELAPSED TIME - SEEMINGLY RANDOM
STALL WARNING = 1 // RESULT WILL EITHER RETURN 0 OR 1 REGARDLESS OF THE VALUE THE APP SHOULD BE SENDING AT THAT TIME
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub try { String line; InputStreamReader Isr = new InputStreamReader(Ignition().getInputStream()); BufferedReader input = new BufferedReader(Isr); { while ((line = input.readLine()) != null) { line = input.readLine(); System.out.println(line); line = input.readLine(); System.out.println(line); } input.close(); } } catch (Exception e) { e.printStackTrace(); } Ignition().destroy(); System.out.println("Program ended"); } public static Process Ignition() throws IOException{ String appname = new String("TaggedData.exe"); String Fname = new String("C:\\Users...\"+ appname); String command[] = {Fname}; ProcessBuilder Prep =new ProcessBuilder(command); Process P3d = Prep.start(); return P3d ; } }