什么意思?不太明白,你是想做一个Java程序,捕获hi.exe在屏幕上产生的输出吗?

解决方案 »

  1.   

    PrintStream out =
          new PrintStream(
            new BufferedOutputStream(
              new FileOutputStream("test.out")));    
    System.setOut(out);
    System.setErr(out);
    Runtime.getRuntime().exec("hi.exe");输出保存到文件test.out外
      

  2.   

    java.lang.Process
    abstract  InputStream getErrorStream() 
              Gets the error stream of the subprocess. 
    abstract  InputStream getInputStream() 
              Gets the input stream of the subprocess. 
    可以看看这个类,但是我没有搞定:(
    希望你搞定了告诉我一声:)
      

  3.   

    我try下
    arefe(arefe) 你的方法我也没搞定
      

  4.   

    ilka()的做个临时输出文件也是个好办法,呵呵....
      

  5.   

    try{
                 Process process = Runtime.getRuntime().exec("hi.exe");
                 String output;
              
                 BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream())); 
                 while ( (output=bufferedReader.readLine()) != null)
    {
    ....
    }
    }
    catch(Exception e){....}
      

  6.   

    还有个问题
    在98下怎么通过java调用内部命令
    比如dir