java实现ping
程序员文章站
2023-11-10 10:54:58
java实现ping...
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());
}
}
}
}
}
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());
}
}
}
}
}
上一篇: PHP 危险函数解释
下一篇: 钉钉电脑端怎么关闭声音提醒?