Java tutorial
//package com.java2s; import java.io.*; public class Main { /** * Run a command with the given data as input. */ public static void systemIn(String command, String data) throws Exception { String cmd[] = new String[3]; cmd[0] = System.getProperty("SHELL", "/bin/sh"); cmd[1] = "-c"; cmd[2] = command; Process p = Runtime.getRuntime().exec(cmd); PrintWriter w = new PrintWriter(p.getOutputStream()); w.print(data); w.flush(); w.close(); p.waitFor(); } }