import java.io.*;public class MethodInProcess {
    public static void main(String[] args) {
        try{
            String s = new String("java StringStream");
   Process p = Runtime.getRuntime().exec(s);
   BufferedReader bufReader = new BufferedReader(
               new InputStreamReader(
     p.getInputStream()));
   String line;
   while((line = bufReader.readLine()) != null){
   System.out.println(line);
            }
        }catch(IOException e){
         }
    }
}public class StringStream { public static void main(String[] args) {
System.out.println("one");
System.out.println("two");
System.out.println("three");
System.out.println("four");
System.out.println("five");
}
}运行第一个类会有第二个类中相应的输入...可是我不知道如何在第一个类中去运用
p.getOutputStream()...其实我的主要目的是能在两个类之间有个交互的过程..即当我的第一个类
接受到了第二个类中匹配的字符后,第一个类会传一些字符给第二个类...该如何实现呢...?

解决方案 »

  1.   

    FAQ里面有个这方面的资料,你查一下先,我记得原来也是我整理的,我现在不在自己的电脑上,不知道具体的URL,你查一下。
      

  2.   

    找了,但是没找到答案...请指教...YuLimin GG..... :)Thanks a lot...
      

  3.   

    我需要一些p.getOutputStream()的例子,我现在是不会用该方法~谢了各位~~
      

  4.   

    寻人启事.. 
        YuLimin...以前的总结在哪里可以找到呀?
        谢了先..
      

  5.   

    用get set方法就可以了啊,为什么要新开进程啊?你这种需求连线程都不用开,直接调用对方的方法不就完了,如果类在远程的,可以用remote call或socket技术