Vamos a conectar con una URL en groovy.
String address = "www.google.es"Y esto es todo sencillo no???
def urlInfo = address.toURL()
println "URL: ${address}"
println "urlInfo: ${urlInfo}"
println "Host/Port: ${urlInfo.host}/${urlInfo.port}"
println "Protocol: ${urlInfo.protocol}"
def connection = urlInfo.openConnection()
println "Connection Type: ${connection.class}"
println "Content Type: ${connection.contentType}"
println "Response Code/Message: ${connection.responseCode} / ${connection.responseMessage}"
println "Request Method: ${connection.requestMethod}"
println "Date: ${connection.date}"
println "Last-Modified: ${connection.lastModified}"
println "Content Length: ${connection.contentLength}"
Comentarios