Sending Input to a Command : Process « Development « Java Tutorial






import java.io.OutputStream;

public class Main {
  public static void main(String[] argv) throws Exception {
    String command = "cat";
    Process child = Runtime.getRuntime().exec(command);

    OutputStream out = child.getOutputStream();

    out.write("some text".getBytes());
    out.close();
  }
}








6.27.Process
6.27.1.Reading Output from a Command
6.27.2.Sending Input to a Command
6.27.3.Execute external command and obtain the result
6.27.4.Helper method to execute shell command