Not able to download file using AWS

I am using this class "DSS2OnDemandTicksTRTH" from the java examples to download data through AWS. I am able to get the AWS URI and able to download the file by hitting that link from browser.

However, through java code I am not able to download the file. I am encountering a connection timed out error in this line:

GzipCompressorInputStream gis = new GzipCompressorInputStream( myURLConnection.getInputStream(), true);

I have made a jar of the class and am running it from unix shell. Any help is much appreciated.