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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:34:33+00:00 2026-05-26T14:34:33+00:00

I have a silly problem i haven’t been able to figure out. Can anyone

  • 0

I have a silly problem i haven’t been able to figure out. Can anyone help me?
My Code is as:

String zipname = "C:/1100.zip";
    String output = "C:/1100";
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    try {
        ZipFile zipFile = new ZipFile(zipname);
        Enumeration<?> enumeration = zipFile.entries();
        while (enumeration.hasMoreElements()) {
            ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
            System.out.println("Unzipping: " + zipEntry.getName());
            bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
            int size;
            byte[] buffer = new byte[2048];

It doesn’t create a folder but debugging shows all the contents being generated.
In Order to create a folder i used the code

if(!output.exists()){ output.mkdir();} // here i get an error saying filenotfoundexception

            bos = new BufferedOutputStream(new FileOutputStream(new File(outPut)));
            while ((size = bis.read(buffer)) != -1) {
                bos.write(buffer, 0, size);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        bos.flush();
        bos.close();
        bis.close();
    }

My zip file contains images: a.jpg b.jpg… and in the same hierarchy, I have abc.xml.
I need to extract the content as is in the zip file.
Any helps here.

  • 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-26T14:34:34+00:00Added an answer on May 26, 2026 at 2:34 pm

    There are a few problems with your code: Where is outPut declared? output is not a file but a string, so exists() and mkdir() do not exist. Start by declaring output like:

    File output = new File("C:/1100");
    

    Furthermore, outPut (with big P) is not declared. It be something like output + File.seprator + zipEntry.getName().

     bos = new BufferedOutputStream(new FileOutputStream(output + File.seprator + zipEntry.getName()));
    

    Note that you don’t need to pass a File to FileOutputStream, as constructors show in the documentation.

    At this point, your code should work if your Zip file does not contain directory. However, when opening the output stream, if zipEntry.getName() has a directory component (for instance somedir/filename.txt), opening the stream will result in a FileNotFoundException, as the parent directory of the file you try to create does not exist. If you want to be able to handle such zip files, you will find your answer in: How to unzip files recursively in Java?

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

Sidebar

Related Questions

I may be having a silly problem here... I can't seem to figure out
Okay, I'm kinda stuck on really silly problem, but still can't figure out. I'm
I need your help to solve a silly problem. I have 2 tables in
Stuck with a silly problem. I have an input field, where user can input
I have a really silly problem that has cost me a load of time
I have a silly, little class FileSystemSize which can be used both as an
I have been stuck on this silly if statement, whatever i do, I cannot
Problem I'm fairly new to design patterns, and have been studying the book, Head
This is perhaps a rather silly problem. I have a CheckBox on my page
I have a (hopefully silly) iPhone programming question. I'm trying to get a string

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.