exec « API « Java I/O Q&A





1. Writing data to InputStream of grep program invoked in java    stackoverflow.com

I'm trying to process data obtained from a run of diff to an instance of GNU grep in a java program. I've managed to get the output of diff using the ...

2. Reading streams from java Runtime.exec    stackoverflow.com

I have the following snippet of code: Process proc = runtime.exec(command); errorGobbler = new ErrorStreamGobbler(proc.getErrorStream(), logErrors, mdcMap); outputGobbler ...

3. Runtime.getRuntime().exec("C:\cygwin\bin\bash.exe") has no input to read    stackoverflow.com

I'm trying to execute a new process and read from its input stream in Java. I have successfully used Runtime.getRuntime().exec(String) to start and receive input from several processes. However, when I ...

4. Printing Runtime exec() OutputStream to console    stackoverflow.com

I am trying to get the OutputStream of the Process initiated by exec() to the console. How can this be done? Here is some incomplete code:

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;

public ...

5. Multiple processes share the same output/input streams    stackoverflow.com

I wrote a java program to start a C program as a process and I create many processes of that C program that are working simultaneously, and each process log its ...

6. how to avoid getRuntime.exec() to block when reading inputStream?    stackoverflow.com

I call a class which is located somewhere in a jar file (using java -classpath path/file.jar classname) within my java code. My problem is when the command genKOSCommand is invalid the call ...

8. Providing input to the child process' inputstream using Runtime.exec    forums.oracle.com

String[] arr = {"/usr/bin/bash", "/var/tmp/gsh" }; Runtime rt = Runtime.getRuntime(); try { Process child = Runtime.getRuntime().exec(arr); //Invoke a thread to monitor the generated output. class monitorThread extends Thread { InputStream in; StringBuffer buffer = new StringBuffer(); monitorThread(InputStream in) { this.in = in; } public void run() { try { InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedReader(isr); String output; ...

9. InputStream problem with Runtime.exec    forums.oracle.com

public void run(){ try{ InputStreamReader isr = new InputStreamReader(is); while(true){ if(isr.ready()){ System.out.println("Its ready!"); //HERE!!! break; } } BufferedReader br = new BufferedReader(isr); String line = null; while ( (line = br.readLine()) != null){ System.out.println(line); } isr.close(); is.close(); } catch (Exception ioe){ ioe.printStackTrace(); } } } Notice that i am never getting isr.ready() = true!