Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:15:07+00:00 2026-06-04T01:15:07+00:00

I am trying to programmatically decompress a .xml.gz file. It seems to be all

  • 0

I am trying to programmatically decompress a .xml.gz file. It seems to be all pretty straightforward as there are many examples available on the internet which tell you how to decompress a .gz file. However, every-time I try to do it, I get an exception: java.io.IOException: unknown format (magic number d4d4).

I’m trying to do this in an Android app, is it supposed to be done differently from the way its done otherwise in Java?

I’m following this example code available here.

Anyone have any idea what I’m doing wrong here? Also, I’m decompressing the file after I have downloaded it from the a web server. The download seems to have worked fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:15:09+00:00Added an answer on June 4, 2026 at 1:15 am

    Found a nice way of downloading an decompressing at the same time. It works like a breeze.

    protected String doInBackground(String... sUrl) {
        try {
            URL url = new URL(sUrl[0]);
            URLConnection connection = url.openConnection();
            InputStream stream = connection.getInputStream();
            stream = new GZIPInputStream(stream);
            InputSource is = new InputSource(stream);
            InputStream input = new BufferedInputStream(is.getByteStream());
            OutputStream output = new FileOutputStream("Path to the file");
            byte data[] = new byte[2097152];
            long total = 0;
            int count;
    
            while ((count = input.read(data)) != -1) {
                total += count;
                output.write(data, 0, count);
            }
    
            output.flush();
            output.close();
            input.close();
        } catch (BufferOverflowException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
    

    Reference: http://abhirampal.com/2012/05/17/android-download-decompress-gzip/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to programmatically add a <meta> . It is working fine when there
I'm trying to programmatically send an email of all of the dll files and
I'm trying to programmatically replace <? with <?php in a bunch of file, but
I am trying to programmatically reduce (lossy) the file size of PNG and GIF
I'm trying to programmatically verify that a jar file has not been obviously tampered
Im trying to programmatically post to an html form on the internet.I have managed
I was trying to programmatically go through presidential campaign contributions to see which web
I'm trying to programmatically check file associations by the file extension (for example .jnlp
Trying to programmatically add options to a SELECT drop down in IE Windows Mobile.
I'm trying to programmatically add an Execute SQL task from within a script task

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.