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 549395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:10:48+00:00 2026-05-13T11:10:48+00:00

I am trying to write a function which will accept an InputStream with zipped

  • 0

I am trying to write a function which will accept an InputStream with zipped file data and would return another InputStream with unzipped data.

The zipped file will only contain a single file and thus there is no requirement of creating directories, etc…

I tried looking at ZipInputStream and others but I am confused by so many different types of streams in Java.

  • 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-05-13T11:10:48+00:00Added an answer on May 13, 2026 at 11:10 am

    Concepts

    GZIPInputStream is for streams (or files) zipped as gzip (".gz" extension). It doesn’t have any header information.

    This class implements a stream filter for reading compressed data in the GZIP file format

    If you have a real zip file, you have to use ZipFile to open the file, ask for the list of files (one in your example) and ask for the decompressed input stream.

    Your method, if you have the file, would be something like:

    // ITS PSEUDOCODE!!
    
    private InputStream extractOnlyFile(String path) {
       ZipFile zf = new ZipFile(path);
       Enumeration e = zf.entries();
       ZipEntry entry = (ZipEntry) e.nextElement(); // your only file
       return zf.getInputStream(entry);
    }
    

    Reading an InputStream with the content of a .zip file

    Ok, if you have an InputStream you can use (as @cletus says) ZipInputStream. It reads a stream including header data.

    ZipInputStream is for a stream with [header information + zippeddata]

    Important: if you have the file in your PC you can use ZipFile class to access it randomly

    This is a sample of reading a zip-file through an InputStream:

    import java.io.FileInputStream;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    
    
    public class Main {
        public static void main(String[] args) throws Exception
        {
            FileInputStream fis = new FileInputStream("c:/inas400.zip");
    
            // this is where you start, with an InputStream containing the bytes from the zip file
            ZipInputStream zis = new ZipInputStream(fis);
            ZipEntry entry;
                // while there are entries I process them
            while ((entry = zis.getNextEntry()) != null)
            {
                System.out.println("entry: " + entry.getName() + ", " + entry.getSize());
                        // consume all the data from this entry
                while (zis.available() > 0)
                    zis.read();
                        // I could close the entry, but getNextEntry does it automatically
                        // zis.closeEntry()
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 304k
  • Answers 304k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would say no; with the exception of 'dead code'… May 13, 2026 at 8:49 pm
  • Editorial Team
    Editorial Team added an answer You need to be more precise about "the object". If… May 13, 2026 at 8:49 pm
  • Editorial Team
    Editorial Team added an answer I can't say for sure with such a vague question,… May 13, 2026 at 8:49 pm

Related Questions

I am trying to write a template function which will extract the value of
I am trying to write a function that will take an xml object, an
This is probably a question for an x86 FPU expert: I am trying to
I have two tables (in postgres) - ads and logs. After every insert into
Sorry, that's the best subject I can come up with, if I understood the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.