编写类似ping命令的 编写类似ping命令的 大概个点想法 就行 我的意思是想获得 连接 的 响应毫秒 给个例子好吗 我没找到 那个类的方法!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下ping 192.168.0.1 可以用args 来传参数,以达到动态ping某个IPimport java.io.*;public class Test{ public static void main(String[] args) throws Exception { Process pro = Runtime.getRuntime().exec("ping 192.168.0.1"); pro.waitFor(); BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream())); String str = br.readLine(); while(str != null) { System.out.println(str); str = br.readLine(); } }}运行如下:F:\>java TestPinging 192.168.0.1 with 32 bytes of data:Reply from 192.168.0.1: bytes=32 time<1ms TTL=128Reply from 192.168.0.1: bytes=32 time<1ms TTL=128Reply from 192.168.0.1: bytes=32 time<1ms TTL=128Reply from 192.168.0.1: bytes=32 time<1ms TTL=128Ping statistics for 192.168.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms 解析获得到的串,比如获取Average后的值. 向XML文件中增加新的元素 数组求解! 读入相同的文件,会占用更多的内存吗? 在java中,byte类型和int类型的相互转换的问题 哪位有能播放声音文件的java代码?多谢了 如何获得网卡信息 邮件发送需要进行身份认证,如何进行处理? 紧急求助,谁能解决我的问题,500分想送 哪里有用JAVA读取 MS-Excel文件的包?谢谢谢谢 代码中有不解之处请解释一下 关于Vector的问题 comm.jar操作串口,出现WaitCommEvent错误,急,请大家帮忙?
{
public static void main(String[] args) throws Exception
{
Process pro = Runtime.getRuntime().exec("ping 192.168.0.1");
pro.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String str = br.readLine();
while(str != null)
{
System.out.println(str);
str = br.readLine();
}
}
}运行如下:
F:\>java TestPinging 192.168.0.1 with 32 bytes of data:
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Reply from 192.168.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms