How to read a .gz file that's stored on a remote server?

Hi,

Would anyone be able to guide me with how to read a .gz file that's stored on a remote server?  I know how to read a regular file using a URLConnection etc. but I'm not sure how to read from a .gz file.

Thanks for your help

pw05Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

radarshCommented:
You need to use the GZIPInputStream to read it.

________
radarsh
CEHJCommented:
InputStream gz = new GZipInputStream(url.openStream());

would be the heart of it
StillUnAwareCommented:
use java.util.zip.GZipInputStream:

GZipInputStream gz = new GZipInputStream(<inputstream from url>);
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

CEHJCommented:
Typo. SHould be

InputStream gz = new GZIPInputStream (url.openStream());
radarshCommented:
Connect using the normal way only, using URLConnection but wrap the inputstream you get

using:  GZIPInputStream gis = new GZIPInputStream(urlconnection.getInputStream());

________
radarsh

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pw05Author Commented:
After I get the GZIPInputStream, how would I read it line by line?

(For regular files I use BufferedReader readLine() - is there a corresponding idea of a "line" using GZIPInputStream read()?)

Thanks
pw05Author Commented:
oh, I think I can just wrap the BufferedReader
CEHJCommented:
pw05 - any reason why my answer was ignored?
pw05Author Commented:
CEHJ - I didn't try url.openStream - I thought it had to be urlconnection.getInputStream

sorry about that
CEHJCommented:
No, but never mind ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.