我写了一个C语言程序,现在想用Runtime.exec来执行它,c语言代码如: 
mytest.c文件 
#include <stdio.h> int main() 

  int i; 
  scanf("%d",&i); 
  printf("%d^2=%d",i,i*i); 
  return 0; 

这个程序中运行时需要输入数据(scanf("%d",&i);),请问各位用java应该输入才能实现数据的输入和数据的输出拦截。 
在这里先谢谢各位了!希望能给小弟一小段代码 
import java.io.BufferedInputStream; 
  import java.io.IOException; 
   
  public class ExecLs { 
   
   static public void main(String[] args) { 
   String cmd = "mytest.exe" 
   
   try { 
   Process ps = Runtime.getRuntime().exec(cmd); 
    /*这里改如何把输入数据??????????*/ 
   System.out.print(loadStream(ps.getInputStream())); 
   System.err.print(loadStream(ps.getErrorStream())); 
   } catch(IOException ioe) { 
   ioe.printStackTrace(); 
   } 
   } 
   
   static String loadStream(InputStream in) throws IOException { 
   int ptr = 0; 
   in = new BufferedInputStream(in); 
   StringBuffer buffer = new StringBuffer(); 
   while( (ptr = in.read()) != -1 ) { 
   buffer.append((char)ptr); 
   } 
   return buffer.toString(); 
   } 
   
  }