250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Thymeleaf
- STS
- 설정
- Spring Boot
- AJAX
- oracle
- MSSQL
- PostgreSQL
- ubuntu
- 문서
- git
- JavaScript
- JDBC
- Eclipse
- IntelliJ
- Open Source
- maven
- spring
- error
- Core Java
- myBatis
- jpa
- Docker
- MySQL
- Source
- Exception
- Python
- Tomcat
- SpringBoot
- 오픈소스
Archives
- Today
- Total
헤르메스 LIFE
[Core Java] 외부명령 실행하기 본문
728x90
String create[] = new String[]{"net.driver", "i:", "\\192.168.1.90\test_drive", "pw", "/user:id"}
Process oProcess = new ProcessBuilder(create).start();
// 스캐너클래스를 사용해 InputStream을 스캔함
//Scanner s = new Scanner(oProcess.getInputStream(), "UTF-8");
Scanner s = new Scanner(oProcess.getInputStream(), "ms949");
while (s.hasNextLine() == true) {
// 표준출력으로 출력
logger.info(s.nextLine());
}
실행결과
더보기
10:04:50.315 [main] DEBUG - create :: net use i: \\192.168.1.90\test_drive pw /user:id 10:04:50.315 [main] DEBUG delete :: net use /delete i: 10:04:50.368 [main] INFO 명령을 잘 실행했습니다. |
728x90
'Core Java' 카테고리의 다른 글
[Source] Apache commons FTPClient Java example - Download files from server (0) | 2022.03.15 |
---|---|
[Core Java] File List 떨구는 샘플 (0) | 2021.03.23 |
[Core Java] QRCode 출력 (1) | 2021.03.23 |
[Core Java] HTML entity 코드 변환 (0) | 2021.03.23 |
한글 Encoding 확인 (0) | 2021.02.08 |