But if you are calling a URL of your own site then you might not want to first compress response on the producer and decompress response on the consumer side. Or your web site is already accessed by lot of other java programs and now if you start gzipping response your afraid that it might break existing clients.
If thats the case then you can figure out what is value of User-Agent header when request is made by Java client, In case if your using Apache Jakarta Commons Http Client, the User Agent header would be set like this
User-Agent Jakarta Commons-HttpClient/3.1
If your using Apache Server for gzipping your response, you can add BrowerMatch statement like this to tell Apache server not to gzip response if the client is Jakarta commons http client
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/json
BrowserMatch ^Jakarta Commons-HttpClient no-gzip