import java.io.*;
public class ExecTest {
public static void main(String[] args) {
try {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("ls -a");
/*標準出力を取得*/
InputStream is = process.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line); //コマンドの結果を返す
}
process.waitFor();
} catch(Exception e) {
e.printStackTrace();
}
}
}
|