import java.io.*;
import java.lang.*;
public class Ping{
public Ping() {
}
public static void main(String args[])
{
String[] addrs= {"www.sina.com"};
if (addrs.length < 1)
{
System.out.println("syntax Error!");
}
else
{
for(int i=0;i<addrs.length;i++){
String line = null;
try
{
Process pro = Runtime.getRuntime().exec("ping " + addrs[i]);
BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while((line = buf.readLine()) != null)
System.out.println(line);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
}
}
【java实现ping】相关文章:
★ 解决VisualStudio提示内存不足、虚拟内存而关闭
★ myEclipse 10中怎么设置tomcat内存大小?
★ visual studio2015中怎么自定义创建vb控件?
★ Sublime Text 3 常用插件以及安装方法(图文)
★ vs2008中文版提供下载(包含中文msdn)附vs2008序列号和破解方法
★ 安装MSDE2000提示“为了安全起见要求使用强 SA 密码
★ 全新Visual Studio Code预览版0.10.10发布下载