http://www.dzone.com/snippets/execute-shell-command-java
01.
String cmd =
"ls -al"
;
02.
Runtime run = Runtime.getRuntime();
03.
Process pr = run.exec(cmd);
04.
pr.waitFor();
05.
BufferedReader buf =
new
BufferedReader(
new
InputStreamReader(pr.getInputStream()));
06.
String line =
""
;
07.
while
((line=buf.readLine())!=
null
) {
08.
System.out.println(line);
09.
}
String cmd = "ls -al";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
pr.waitFor();
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
'Programming' 카테고리의 다른 글
(Haskell) Tutorials (0) | 2012.06.11 |
---|---|
A Concise Introduction to Objective Caml (0) | 2012.06.11 |
How do I download a file using Perl? (0) | 2012.06.08 |
Perl Display And Pass Command Line Arguments With @argv (0) | 2012.06.08 |
(C#) Play Sound Files using libZPlay (0) | 2012.06.07 |