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

  • Home
  • SEARCH
  • 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 8181407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:30:36+00:00 2026-06-07T00:30:36+00:00

I have a zip file containing a folder and inside the folder I have

  • 0

I have a zip file containing a folder and inside the folder I have some image file.I wish to extract these images.However I have not been able to find anything.I have been looking at zipMe but have not been able to find any relevant help.

Below is the code that I have developed so far.

    ZipEntry dataZE;
    InputStream isData;
    StringBuffer sbData;
    ZipInputStream dataZIS;

    String src = "file:///store/home/user/images.zip";
    String path = "file:///store/home/";
    String fileName = "";
    FileConnection f_Conn;

    public UnZipper() {

        debugger("Unzipper constructor");

        try {
            f_Conn = (FileConnection) Connector.open(src);
        } catch (IOException e) {
            debugger("f_conn error :" + e.getMessage());
        }

        try {
            isData = f_Conn.openInputStream();
        } catch (IOException e) {
            debugger("f_conn error getting ip_stream:" + e.getMessage());
        }

        sbData = new StringBuffer();

        dataZIS = new ZipInputStream(isData);

        debugger("got all thing initialized");

    }

    public void run() {

        debugger("unzipper run");

        try {
            startUnziping();
        } catch (IOException e) {

            debugger("Error unzipping " + e.getMessage());
        }

        debugger("finished...");

    }


    private void startUnziping() throws IOException {

        debugger("startUnziping");
        dataZE = dataZIS.getNextEntry();
        fileName = dataZE.getName();
        writeFile();
        dataZIS.closeEntry();

        debugger(">>>>>>>>>>> : " + fileName);
    }

    private void readFile() throws IOException {

        debugger("readFile");
        int ch;
        int i = 0;
        while ((ch = dataZIS.read()) != -1) {

            debugger((i++) + " : " + sbData.toString()
                    + " >>> writting this..");
            sbData.append(ch);
        }

    }

    private void writeFile() {

        debugger("writting file...");
        FileConnection f_Conn = null;
        byte[] file_bytes = new byte[sbData.length()];
        file_bytes = sbData.toString().getBytes();

        try {
            readFile();
        } catch (IOException e) {
            debugger("Error while reading " + e.getMessage());
        }

        try {
            f_Conn = (FileConnection) Connector.open(path + fileName);
        } catch (IOException e) {
            debugger("getting f_conn" + e.getMessage());
        }

        if (!f_Conn.exists()) {
            // create the file first
            debugger("I know file does not exists");
            try {
                f_Conn.mkdir();
            } catch (IOException e) {
                debugger("Oops!!! error creating fle : " + e.getMessage());
            }
        }
        try {
            f_Conn.setWritable(true);
            debugger("file is nt writeable");
        } catch (IOException e) {
            debugger("cannot make it writeable : " + e.getMessage());
        }
        OutputStream lo_OS = null;
        try {
            lo_OS = f_Conn.openOutputStream();
            debugger("got out Stream hero!!!");
        } catch (IOException e) {
            debugger("cant get out Stream !!!");
        }
        try {
            lo_OS.write(file_bytes);
            debugger("yess...writtent everything");
        } catch (IOException e) {
            add(new LabelField("Error writing file ..." + e.getMessage()));
        }
        try {
            lo_OS.close();
            debugger("now closing connection...");
        } catch (IOException e) {
            debugger("error closing out stream : " + e.getMessage());
        }

    }
}

I have been able to get ZipEntry representing folder that contains images however I have not been able to figure out how i must extract those images.

Thanks for help.

  • 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-07T00:30:39+00:00Added an answer on June 7, 2026 at 12:30 am

    Iterate over all ZipEntry in zip file in you startUnzipping (you’re working only with first one in your code). The item corresponded to child file should have name like “foldername/filename“.

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

Sidebar

Related Questions

I have an HTML file containing these lines - <script>PrintFileURL("13572_BranchInformationReport_2012-06-29.xml","13572_BranchInformationReport_2012-06-29.zip",0,"184277","Jun 29 1:30","/icons/default.gif")</script> <script>PrintFileURL("13572_BranchInformationReport_2012-07-02.zip","13572_BranchInformationReport_2012-07-02.zip",0,"184302","Jul 2
I have a zip file that contains folder hierarchies and files. \images\ \images\1.jpg \images\2.jpg
I have a zip file which has one base folder inside it with other
I have a zip file containing pdf, .exe inside. When I am using FF
I have a Zip archive with a large (important) file that will not extract.
I have a zip file containing a folder structure like main-folder/ subFolder1/ subFolder2/ subFolder3/
I have inherited some code (from zip file) from a developer and git initialzed,
I try to extract all files from .zip containing subfolders in one folder. I
In this situation, I have created a zip file containing search result files, and
I have a war file which does not contains manifest not even META-INF folder.

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.