IT/JAVA

Java ProcessBuilder, Runtime,, linux 에서 사용하기

최고영회 2013. 12. 21. 12:33
728x90
반응형
SMALL
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class ExecTest {
public static void main(String args[]) throws IOException {
String[] command = {"/bin/sh", "-c", "/test/test_shell.sh"};
try{
Process ps = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
String line;
while( (line = br.readLine()) != null){
System.out.println(line);
}
ps.waitFor();
ps.destroy();
}catch(Exception e){
e.printStackTrace();
}
}
}


728x90
반응형
LIST