集册 Java实例教程 IP是否可访问

IP是否可访问

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

412
IP是否可访问


//package com.nowjava;// from 时   代     Java  公  众  号 - nowjava.com

import java.net.InetAddress;


public class Main {


    public static boolean isReachable(String ip, int timeout) {

        try {

            InetAddress address = InetAddress.getByName(ip);

            return address.isReachable(timeout);

        } catch (Exception e) {

            e.printStackTrace();

        }

        return false;

    }
    /**
    来 自 n o w  j a v a  . c o m
    **/


    public 
展开阅读全文