带壳Ping

—— 带壳平

欢马劈雪     最近更新时间:2020-01-02 10:19:05

468
带壳平
//时代Java - N o w  J a v a . c o m


//package com.nowjava;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;


public class Main {

    public static String ping(String url) {

        String str = "";

        try {

            Process process = Runtime.getRuntime().exec(

                    "/system/bin/ping -c 3 " + url);

            BufferedReader reader = new BufferedReader(

                    new InputStreamReader(process.getInputStream()));

            int i;

            char[] buffer = new char[4096];

            StringBuffer output = new StringBuffer();

            while ((i = reader.read(buffer)) > 0)

                output.append(buffer, 0, i);

            reader.close();

            str = output.toString();
  
展开阅读全文