728x90
반응형

grooy script에서 HostName 또는 Domain name으로 Ip address를 확인하고 싶은 경우가 있다. 

그럴 경우에는 InetAddress.getByName()을 사용하면 Host IP 와 name을 가진 InetAddress Structure를 리턴한다. 

def hostname = 'google.com'
println InetAddress.getByName(hostname).address.collect { it & 0xFF }.join('.')

 

728x90
반응형

+ Recent posts