日期:2014-05-20  浏览次数:20665 次

请教process.getInputStream()的问题
Java code

Process process = Runtime.getRuntime().exec ("cmd.exe"); 
              BufferedReader   bufferedReader   =   new   BufferedReader(   new   InputStreamReader(process.getInputStream()));     



    
             String line;  

    
             while ((line = bufferedReader.readLine ()) != null)  
             {
                 System.out.println(line);
                 System.out.flush();   
             }


在while ((line = bufferedReader.readLine ()) != null) 时前两行可以输出,
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
再往下到了while ((line = bufferedReader.readLine ()) != null) 的时候就不动了,程序就卡在那里了,请问这是怎么回事?谢谢啦


------解决方案--------------------
你在循环的的最后面应该在让他读一遍!