Ping (1) 썸네일형 리스트형 [안드로이드] 코드에서 Ping 확인 Java /** * @return 0: success, 1: fail, 2: error */ public static int ping(@NonNull String host, int timeout) throws InterruptedException, IOException { int res; Runtime rt = Runtime.getRuntime(); Process process = rt.exec(String.format(Locale.US, "ping -c 1 -W %d %s", timeout, host)); // 0: 성공, 1: 실패, 2: 에러 res = process.waitFor(); // ~~ // shell 명령 출력 값 확인용입니다. 없어도 되요 BufferedReader br = new B.. 이전 1 다음