我想抛出一个异常,当用户输入无效的IP地址、主机名或不是完全限定的域名时,会弹出一条错误消息。
我不太确定是使用unknownhostexception还是IOException。
我试着做if语句,但我不知道在java中什么是“无效”。
If (addr != ' not a valid IP address, host name, fully qualified domain name or entered something invalid ')
{
throw new IOException/UnknownHostException("this is inval
我的web应用程序上有允许输入域/IP地址的字段。用户可以通过混合以下值来指定:
10.10.10.
或
-domain.com
对于有关IP和域名的RFCs,这两个值都是不正确的。我使用番石榴库中的下列验证器进行验证:
InetAddresses
InternetDomainName
我的目标是确定是否有用户指定了错误的IP或域,并显示与其相关的消息。
Ex: if user specifes "-domain.com". Alert shoud be appear with message "Wrong domain name is specified"