1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import java.io.BufferedReader import java.io.InputStreamReader fun main() { val host = "google.com" // Cambia esto por la dirección IP o el nombre de host que desees val command = "ping $host" val process = Runtime.getRuntime().exec(command) val reader = BufferedReader(InputStreamReader(process.inputStream)) var line: String? while (reader.readLine().also { line = it } != null) { println(line) } reader.close() } |