How can you check whether domain exists or not in Java?

前端 未结 5 1224
死守一世寂寞
死守一世寂寞 2020-12-17 20:57

Suppose my email address is xyz@yahoo.com and I want to check if yahoo.com is a valid domain or not.

Can anyone tell me which Java API I ca

5条回答
  •  暖寄归人
    2020-12-17 21:23

    You can use org.apache.commons.validator.routines.DomainValidator.

    First add maven dependency

    
            commons-validator
            commons-validator
            1.6
    
    

    then:

    boolean isValid = DomainValidator.getInstance().isValid("yahoo.com");
    

提交回复
热议问题