Skip to content

Instantly share code, notes, and snippets.

@erik
Created May 5, 2010 22:26
Show Gist options
  • Save erik/391540 to your computer and use it in GitHub Desktop.
Save erik/391540 to your computer and use it in GitHub Desktop.
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