Java外部C言語プログラムを呼び出し、標準入出力操作を行う
1349 ワード
import java.lang.*;
class test3{
public static void main(String []args) throws IOException{
long a = System.currentTimeMillis();
Process process = Runtime.getRuntime().exec("/home/xxx");// , process
PrintStream outputWriter = new PrintStream(new BufferedOutputStream(process.getOutputStream()));
outputWriter.println("XXXX");
outputWriter.flush();// ,
outputWriter.println("XXX");
outputWriter.flush();
outputWriter.println("XXX");
outputWriter.flush();
outputWriter.println("XXX");
outputWriter.flush();
outputWriter.println("XXX");
outputWriter.flush();
BufferedReader addResult = new BufferedReader(
new InputStreamReader(process.getInputStream())
);
String line;
while((line=addResult.readLine())!=null)
{
System.out.println(line);
}
long b = System.currentTimeMillis();
System.out.println(b-a);
}
}