'시스템명령'에 해당되는 글 1건
시스템 명령을 실행해서 결과 뿌리기 :: 2007/05/11 11:51
/Java
import java.io.*;
public class SystemExec {
public static void main(String[] args) {
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(args);
InputStream in = p.getInputStream();
for(int ch; (ch = in.read()) != -1;)
System.out.write(ch);
}
catch (IOException ioe) {
ioe.printStackTrace();
}
System.exit(0);
}
}
|
실행결과: > java SystemExec ls / |

