java - How can I check if a String is an IP in Groovy? -
from given string:
string someip = // string
how can check, if someip valid ip format?
you can use inetaddressvalidator class check , validate weather string valid ip or not.
import org.codehaus.groovy.grails.validation.routines.inetaddressvalidator ... string someip = // string if(inetaddressvalidator.getinstance().isvalidinet4address(someip)){ println "valid ip" } else { println "invalid ip" } ...
try this..,.
Comments
Post a Comment