○Process
▷실행중인 프로그램
▶생성 : Process 클래스로 또 다른 프로그램을 실행 가능하다.
▷Process proc = Runtime.getRuntime().exec("프로그램명");
▷Process proc = new ProcessBuilder("cmd", "\c", "dir").start();
▶Input/Output/Error 상호작용
▷만들어진 프로세스와 input/output/error steams를 주거나 받을 수 있다.
▶InputStream 선언 : InputStream in = proc.getInputStream()
▷읽기 : in.read(buffer, off, len) - buffer는 byte[], byte[off]부터 len개, return: 읽은 byte 수
▷닫기 : in.close
▶OutputStream 선언 : OutputStream out = proc.getOutputStream()
▷읽기 : out.write(buffer) - buffer는 byte[], byte[off]부터 len개
▷닫기 : out.close
'컴퓨터 언어 > java' 카테고리의 다른 글
Stream (0) | 2020.12.01 |
---|---|
Thread (0) | 2020.11.24 |
Exception (0) | 2020.11.19 |
Lambda Expression (0) | 2020.11.16 |
Collection (0) | 2020.11.16 |