Javaでシェル(shell)を実行して、出力結果を読み込むサンプル

Javaコード:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Startnews24_shell {

public static void main(String args[])
{
try {
Process p = Runtime.getRuntime().exec(“cmd ver");
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);
System.out.println(br.readLine());

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Java

Posted by arkgame