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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:10:56+00:00 2026-06-08T12:10:56+00:00

I have a folder /mnt/sdcard/Bluetooth which contains several zip files. Each of this zip-files

  • 0

I have a folder /mnt/sdcard/Bluetooth which contains several zip files. Each of this zip-files contains only one file. How can I extract the content for each of these zip-files into a new file, containing the content of each zip-file? This is what I’ve done so far:

public class Main extends Activity {

Object[] arrayOfRarFiles;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String path = "/mnt/sdcard/Bluetooth";
    String nameOfFiles;
    File folder = new File(path);
    File[] listOfFiles = folder.listFiles();

    for (int i = 0; i < listOfFiles.length; i++) {
        if (listOfFiles[i].isFile()) {
            nameOfFiles = listOfFiles[i].getName();

            if (nameOfFiles.endsWith(".zip")
                    || nameOfFiles.endsWith(".ZIP")) {

                try {
                    extractFile(nameOfFiles);
                } catch (FileNotFoundException e) {
                    Log.e("EXTRACTFILE SAYS: ", e.getMessage());
                }

            }
        }
    }
}

public void extractFile(String path) throws FileNotFoundException {

    String zipFileName = "/mnt/sdcard/Bluetooth/" + path;
    String extractedFileName = getApplicationContext().getFilesDir()
            .getPath().toString()
            + "Finger.FIR";

    ZipInputStream inStream = new ZipInputStream(new FileInputStream(
            zipFileName));
    OutputStream outStream = new FileOutputStream(extractedFileName);





    Toast.makeText(getApplicationContext(), zipFileName,
            Toast.LENGTH_SHORT).show();

}

The last toast, in the extractFile method outputs the name of each zip-file. The file inside the zip-folders are .FIR files

  • 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-08T12:10:57+00:00Added an answer on June 8, 2026 at 12:10 pm

    I think you can use the following function which I’ve found in another SO question.

    Pay attention to set your path and file name parameters correctly based on your need.

    public void extractFile(String path) throws FileNotFoundException {
    
        String zipFileName = "/mnt/sdcard/Bluetooth/" + path;
        String extractedFileName = getApplicationContext().getFilesDir()
                .getPath().toString()
                + "Finger.FIR";
    
        ZipInputStream inStream = new ZipInputStream(new FileInputStream(
                zipFileName));
        OutputStream outStream = new FileOutputStream(extractedFileName);
    
        unpackZip(path ,zipFileName)
    
    
    
        /*Toast.makeText(getApplicationContext(), zipFileName,
                Toast.LENGTH_SHORT).show();*/
    
    }
    
    private boolean unpackZip(String path, String zipname)
    {       
         InputStream is;
         ZipInputStream zis;
         try 
         {
             String filename;
             is = new FileInputStream(path + zipname);
             zis = new ZipInputStream(new BufferedInputStream(is));          
             ZipEntry ze;
             byte[] buffer = new byte[1024];
             int count;
    
             while ((ze = zis.getNextEntry()) != null) 
             {
                 // zapis do souboru
                 filename = ze.getName();
                 FileOutputStream fout = new FileOutputStream(path + filename);
    
                 // cteni zipu a zapis
                 while ((count = zis.read(buffer)) != -1) 
                 {
                     fout.write(buffer, 0, count);             
                 }
    
                 fout.close();               
                 zis.closeEntry();
             }
    
             zis.close();
         } 
         catch(IOException e)
         {
             e.printStackTrace();
             return false;
         }
    
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder which contains few files and some directories which I need
I have a html file (contains some text and one image) stored @ /sdcard/test
I have a folder which contains some files that I want to deleted after
So i have a folder at mnt/sdcard/folder and its filled with image files. I
I have a html page which lists all the file names in a folder
I have a file in a folder like this: installer-x86_64-XXX.XX-diagnostic.run where XXX.XX is a
I have folder containing several files and sub-folders such as the following: -/folder -/subfolder
i have folder that contain image files which named with number 1,2,3... how do
In my application I have a config.xml file which is being parsed,. In this
I have folder in which there are no. of html files. Can i count

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.