JAVA>类过程> getOutputStream()突然失效?

时间:2015-05-01 14:44:40

标签: java

我在java工作了7个月的一个项目,代码的和平工作完全正常,直到最近2天,(我怀疑其更新版本8(版本1.8.0-b132)更新的原因2015年4月14日)。

示例代码是

import java.io.IOException;
public class Tri {
    public static void main(String[] args) {
        try{
        Runtime runtime=Runtime.getRuntime();
        Process p=runtime.exec("C:/a.exe");
            byte by[]="1 2".getBytes();
        p.getOutputStream().write(by);
        by=new byte[20];
            p.getInputStream().read(by);
        System.out.println(new String(by));

        }catch(IOException e){
            e.printStackTrace();
        }
}
}

这段代码实际上是做什么的,运行一个由代码

编译的exe文件“a.exe”
#include<stdio.h>
void main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a+b);
}

并且a.exe在命令提示符下正常运行。

a.exe由gcc-4.9-win32_4.9.2-20141023

生成

java代码在2015年4月10日的最后一次运行中运行良好。

现在进程挂起,(因为a.exe正在等待输入,但它没有得到它?)

0 个答案:

没有答案