For a Groovy script using the JDK’s HTTP URL connection, supply the proxy when starting that process:

groovy -Dhttp.proxyHost=proxy.example -Dhttp.proxyPort=8080 fetch.groovy

A small fetch.groovy can then read a text resource:

def url = new URL('http://example.com/')
println url.getText(connectTimeout: 5000, readTimeout: 10000)

The endpoint is illustrative; replace it with an unauthenticated candidate from the HTTP proxy list for this public HTTP text fetch. The host property contains a hostname, and the port is its own property. For an HTTPS destination, configure https.proxyHost and https.proxyPort for the endpoint intended to carry it.

-D defines a JVM system property; it is not a shell environment assignment. Put the options on the Groovy invocation that runs this script. A separate IDE launch or service can start another process with different values.

getText collects the response into a string. It suits a small text fetch; a large download calls for streaming rather than holding the whole result in memory.

འབྲེལ་བའི་རྩོམ་ཡིག