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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:08:01+00:00 2026-05-31T20:08:01+00:00

I got following code from net and it looks everything is proper but i’m

  • 0

I got following code from net and it looks everything is proper but i’m getting File not found exception…

I have a file called NewForestPonies.epub in sdcard

Permission :

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

CODE:

    String ZipFileLocation=Environment.getExternalStorageDirectory()+"/NewForestPonies.epub";
    String unZipFileLocation=Environment.getExternalStorageDirectory()+"/DEST/";
    Decompress decomp=new Decompress(ZipFileLocation, unZipFileLocation, "zip");
    decomp.run(); 



 public Decompress(String zipFile, String location,String t) { 
    super(t);
    _zipFile = zipFile; 
    _location = location; 
} 
public void run() {
    FileInputStream fin=null;
    ZipInputStream zin=null;
    File file =null; 
    ZipEntry ze ;
    FileOutputStream fout=null;
    try{ 
        System.out.println(_zipFile );
        System.out.println(_location);
        fin = new FileInputStream(_zipFile); 
        zin = new ZipInputStream(fin); 
        ze= null; 
        byte[] buffer = new byte[1024];
        int length;
        while ((ze = zin.getNextEntry()) != null) { 
            file = new File((_location +"/" + ze.getName()));
            file.getParentFile().mkdirs();
             fout= new FileOutputStream(_location + ze.getName()); 
            while ((length = zin.read(buffer))>0) {
                fout.write(buffer, 0, length);
            }
            zin.closeEntry(); 
            fout.close();        
        }
        //MyDownloadListener.progress=70;
        zin.close();   
    }catch(Exception e) { 
        Log.e("Decompress", "unzip", e); 
    }  
    finally {

            try {
                fin.close();
                zin.close();
                fout.close();
            } catch (IOException e) {
                e.printStackTrace();
            }




    }

} 

ERRROR:

    03-20 15:49:15.909: ERROR/Decompress(9479): java.io.FileNotFoundException: /mnt/sdcard/DEST/NewForestPonies/iTunesMetadata.plist (Not a directory)
03-20 15:49:15.909: ERROR/Decompress(9479):     at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
03-20 15:49:15.909: ERROR/Decompress(9479):     at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)
03-20 15:49:15.909: ERROR/Decompress(9479):     at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
03-20 15:49:15.909: ERROR/Decompress(9479):     at java.io.FileOutputStream.<init>(FileOutputStream.java:77)
03-20 15:49:15.909: ERROR/Decompress(9479):     at com.AndroidExplorer.Decompress.run(Decompress.java:42)
03-20 15:49:15.909: ERROR/Decompress(9479):     at com.AndroidExplorer.DecompressActivity.onCreate(DecompressActivity.java:23)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.os.Looper.loop(Looper.java:132)
03-20 15:49:15.909: ERROR/Decompress(9479):     at android.app.ActivityThread.main(ActivityThread.java:4028)
03-20 15:49:15.909: ERROR/Decompress(9479):     at java.lang.reflect.Method.invokeNative(Native Method)
03-20 15:49:15.909: ERROR/Decompress(9479):     at java.lang.reflect.Method.invoke(Method.java:491)
03-20 15:49:15.909: ERROR/Decompress(9479):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
03-20 15:49:15.909: ERROR/Decompress(9479):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
03-20 15:49:15.909: ERROR/Decompress(9479):     at dalvik.system.NativeStart.main(Native Method)
  • 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-31T20:08:03+00:00Added an answer on May 31, 2026 at 8:08 pm

    I think the problem in your code is you are closing ZipInputStream zin in 1st while loop.

    Use below code for run(), it may help you.

    public void run() {
        BufferedOutputStream bufferedOutputStream = null;
        FileInputStream fileInputStream;
    
        File dest_file = new File(_location);
        dest_file.mkdirs(); // creates if destination directory not existed    
    
        try {
            fileInputStream = new FileInputStream(_zipFile);
            ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(fileInputStream));
            ZipEntry zipEntry;
    
            while ((zipEntry = zipInputStream.getNextEntry()) != null) {
                String zipEntryName = zipEntry.getName();
                File file = new File(_location + zipEntryName);
    
                if (file.exists()) {
    
                } else if (zipEntry.isDirectory()) {
                    file.mkdirs();
                } else {
                    byte buffer[] = new byte[1024];
                    FileOutputStream fileOutputStream = new FileOutputStream(file);
                    bufferedOutputStream = new BufferedOutputStream(fileOutputStream, 1024);
                    int count;
    
                    while ((count = zipInputStream.read(buffer, 0, 1024)) != -1) {
                        bufferedOutputStream.write(buffer, 0, count);
                    }
                    bufferedOutputStream.flush();
                    bufferedOutputStream.close();
                }
            }
            zipInputStream.close();
        } catch (Exception e) {
            Log.e("Decompress", "unzip", e);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm not good with ADO.NET so used the following code that i got from
I have got the following code from here to read an Excel file using
I've got the following code to output a list of items from amazon, but
I've got the following code to download a binary file from the web: WebClient
I've got the following code from php.net: $GLOBALS['normalizeChars'] = array( 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z',
I've got the following code from another question on SO to track the changing
Ive got the following code which I hacked together from website examples. It works
I need to return server time from a webservice. I've got the following code:
in the following piece of code I got from a book. The NSString *pPath
I got the following code: char buffer[2047]; int charsRead; do { if(fscanf(file, %2047[^\n]%n%*c, buffer,

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.