Guest User

Untitled

a guest
Mar 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. private static String cmdExecute(String arg1, String arg2) {
  2.  
  3. String s;
  4. String str = null;
  5.  
  6. try {
  7.  
  8. //Process oProcess = new ProcessBuilder("cmd", "/c", "dir", "/?").start();
  9. Process oProcess = new ProcessBuilder("cmd", "/c", arg1, arg2).start();
  10.  
  11. // 외부 프로그램 출력 읽기
  12. BufferedReader stdOut = new BufferedReader(new InputStreamReader(oProcess.getInputStream()));
  13.  
  14. while ((s = stdOut.readLine()) != null) {
  15. //System.out.println(s);
  16. str=s;
  17. }
  18.  
  19. } catch (IOException e) { // 에러 처리
  20. e.printStackTrace();
  21. }
  22. return str;
  23. }
  24. }
Add Comment
Please, Sign In to add comment