Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String cmdExecute(String arg1, String arg2) {
- String s;
- String str = null;
- try {
- //Process oProcess = new ProcessBuilder("cmd", "/c", "dir", "/?").start();
- Process oProcess = new ProcessBuilder("cmd", "/c", arg1, arg2).start();
- // 외부 프로그램 출력 읽기
- BufferedReader stdOut = new BufferedReader(new InputStreamReader(oProcess.getInputStream()));
- while ((s = stdOut.readLine()) != null) {
- //System.out.println(s);
- str=s;
- }
- } catch (IOException e) { // 에러 처리
- e.printStackTrace();
- }
- return str;
- }
- }
Add Comment
Please, Sign In to add comment