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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -