我求解java ping程序,即如何在java中实现ICMP??
谢谢各位的帮忙.
谢谢各位的帮忙.
解决方案 »
- 用Tree能和数据库连接并在JTable中显示所需的信息吗
- 修改数据问题~~~~~~~~~~大家帮忙!!!!~~~~~
- 类似EXCEL条件格式效果的实现(有点难(希望大家都来讨论下,发表自己的高见))
- 帮帮我啊
- 学JAVA过程中,我遇到了几个关于main()方法与static修饰符的疑惑.详情请看......
- 怎样得到从键盘输入的数据啊?
- 本人调用一个Jpanel在Applications 中框架的左侧显示,但不知如何传参数过去?江湖救急
- 这段代码错在哪儿?谢谢!
- 紧急求教!究竟Java里面有没有相当于C++的CPOINT的类阿?
- 致 javafounder(漂流)
- winzip的问题还是java的中文问题?
- thinking in java 例程中的一个问题
* ping the server
* @param server String
* @param timeout int
* @return boolean
* @throws IOException
*/
public static boolean pingServer(String server,int timeout)
{
BufferedReader in = null;
Runtime r = Runtime.getRuntime(); String pingCommand = "ping " + server + " -n 1 -w " + timeout;
try
{
Process p = r.exec(pingCommand);
if (p == null)
{
return false;
}
in = new BufferedReader(new InputStreamReader(p.
getInputStream()));
String line = null;
while ( (line = in.readLine()) != null)
{
if (line.startsWith("Reply from"))
{
return true;
}
}
in.close();
}
catch (Exception ex)
{
return false;
}
return false;
}