Capture IO of spawned program in Java
NickName:MTCoster Ask DateTime:2013-03-27T03:08:16

Capture IO of spawned program in Java

I'm writing a program in Java which relies on a pre-compiled third party JAR residing in the same directory as mine. At runtime, my program checks if this file exists, then downloads it if it doesn't. Its main class is then executed. However, the spawned program prints a large amount of text directly to the console. Is there any way to 'capture' (and therefore hide) this output from stdout and return my own input directly from my parent application to stdin? I would ideally like the child program to reside inside the same JVM, so I would like to avoid any version of Runtime.exec().

Copyright Notice:Content Author:「MTCoster」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15645387/capture-io-of-spawned-program-in-java

More about “Capture IO of spawned program in Java” related questions

Capture IO of spawned program in Java

I'm writing a program in Java which relies on a pre-compiled third party JAR residing in the same directory as mine. At runtime, my program checks if this file exists, then downloads it if it does...

Show Detail

Capture output text from a new process spawned from a main process on Windows

I want to capture output of a child process spawned from a parent process. For example, when the parent process runs on a command window like below c:>parent.exe it spawns a child process in a

Show Detail

Capture standard output for Python child spawned by external package

I would like to capture in a file the standard output by a child Process spawned by an external package. I can NOT simply redirect sys.stdout to a file, as this does not capture the output of new

Show Detail

Capture Java process Jmap output

I am running a Java process and simultaneously I am trying to capture the heap size information of the spawned Java process using Java's Jmap utility jmap.exe. I am unable to capture the output

Show Detail

Run Bash from Java Program to Capture Webcam Image on Raspberry Pi

On my Raspberry Pi, I can successfully capture and save images from my Logitech Pro 9000 USB webcam from LXTerminal with the following bash line: fswebcam -d /dev/video0 /home/pi/image.jpg I wan...

Show Detail

Ruby PTY: Capture traceback of spawned process

I'm using Ruby PTY to integration-test a script that takes input and returns corresponding output. The problem is that sometimes this script crashes, raising Errno::EIO. In my case the script cra...

Show Detail

Testing captured IO from a spawned process

I want to test the return value and the IO output on the following method: defmodule Speaker do def speak do receive do { :say, msg } -> IO.puts(msg) speak _ot...

Show Detail

how to capture stdout from embedded jython on java program

i want to use jython on a java program,so i want to capture the stdout in jython script then i can get the output on my java context,is there some way to archive this ?

Show Detail

Which program to use to capture Java output as video

I need to capture the output of a Java Swing program as video for the purpose of demonstration. I have tried Taksi video recorder and CamStudio, both of them are taking the video as a small rectangle

Show Detail

Full screen capture of a DirectX program in java (Javacv ?)

[For Windows] I know it is possible to capture screen of a DirectX program running under C# language, but do you know some sample code for Java? I am actually facing this same problem than this Take

Show Detail