Created
May 5, 2010 22:26
-
-
Save erik/391540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.*; | |
import java.io.*; | |
import java.util.*; | |
public class NetTest { | |
public static void main (String[] args) throws Exception{ | |
String host = "acidrayne.net"; | |
String pingResult = ""; | |
try { | |
Runtime r = Runtime.getRuntime(); | |
Process p = r.exec("ping -c 1 " + host); | |
p.waitFor(); | |
BufferedReader in = new BufferedReader(new | |
InputStreamReader(p.getInputStream())); | |
String inputLine; | |
while ((inputLine = in.readLine()) != null) { | |
System.out.println(inputLine); | |
pingResult += inputLine; | |
} | |
in.close(); | |
} catch (Exception e) { | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment