1

I created a new exe with a C# script which I then execute inside of a Java program. The exe will pull a string from a process that is running and print it to the screen. I was wondering how to access that string in the exe through Java, if there is a way.

k3vy w3vy
  • 121
  • 8
  • 1
    might be best to just have java also pull from the process that is running. Aside from that, could always try some c# / java interop. http://stackoverflow.com/questions/16689/java-and-c-sharp-interoperability – Joshua Jun 22 '15 at 21:03

1 Answers1

3
Process proc = Runtime.getRuntime().exec(...);
InputStream in = proc.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String txt = null;
while ((txt = br.readLine()) != null) {
  //...
}
ControlAltDel
  • 33,923
  • 10
  • 53
  • 80
  • Thank you it worked. I was using the wrong buffer and stream! Much appreciated. Will accept the answer when I can :D – k3vy w3vy Jun 22 '15 at 21:08