?
Solved

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

Posted on 2006-04-05
10
Medium Priority
?
246 Views
Last Modified: 2010-03-31
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

0
Comment
Question by:pw05
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 10

Expert Comment

by:radarsh
ID: 16386047
You need to use the GZIPInputStream to read it.

________
radarsh
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16386055
InputStream gz = new GZipInputStream(url.openStream());

would be the heart of it
0
 
LVL 14

Assisted Solution

by:StillUnAware
StillUnAware earned 400 total points
ID: 16386056
use java.util.zip.GZipInputStream:

GZipInputStream gz = new GZipInputStream(<inputstream from url>);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Expert Comment

by:CEHJ
ID: 16386067
Typo. SHould be

InputStream gz = new GZIPInputStream (url.openStream());
0
 
LVL 10

Accepted Solution

by:
radarsh earned 1600 total points
ID: 16386069
Connect using the normal way only, using URLConnection but wrap the inputstream you get

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

________
radarsh
0
 

Author Comment

by:pw05
ID: 16386273
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
0
 

Author Comment

by:pw05
ID: 16386372
oh, I think I can just wrap the BufferedReader
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16386651
pw05 - any reason why my answer was ignored?
0
 

Author Comment

by:pw05
ID: 16391046
CEHJ - I didn't try url.openStream - I thought it had to be urlconnection.getInputStream

sorry about that
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16391525
No, but never mind ;-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question