1个回答
展开全部
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());
}
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询