📜  java代码示例中的inet类

📅  最后修改于: 2022-03-11 14:52:46.838000             🧑  作者: Mango

代码示例1
er input=new Scanner(System.in);
        String host=input.nextLine();
        try{
            InetAddress ip=InetAddress.getByName(host);
            System.out.println(ip);
            if(ip.isReachable(50)){
                System.out.println("Destination Reached");
            }
            else{
                System.out.println("Destination Unreachable");
            }
        }
        catch (Exception e){
            System.out.println("Invalid domain");
        }