-1

I've been using the unzip code found on this website. The code should be perfectly working, and able to unzip folders/subfolders.

The problem is when I run the code, it gives me errors on logcat:

05-17 20:31:13.415: V/Decompress(27611): Unzipping files/pkey.txt
05-17 20:31:13.430: E/Decompress(27611): unzip
05-17 20:31:13.430: E/Decompress(27611): java.io.FileNotFoundException: /storage/sdcard0/unzipped/files/pkey.txt: open failed: ENOENT (No such file or directory)
05-17 20:31:13.430: E/Decompress(27611):    at libcore.io.IoBridge.open(IoBridge.java:416)
05-17 20:31:13.430: E/Decompress(27611):    at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
05-17 20:31:13.430: E/Decompress(27611):    at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
05-17 20:31:13.430: E/Decompress(27611):    at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
05-17 20:31:13.430: E/Decompress(27611):    at id.ac.petra.ta.DriveActivity$Decompress.unzip(DriveActivity.java:316)
05-17 20:31:13.430: E/Decompress(27611):    at id.ac.petra.ta.DriveActivity$DownloadFile.doInBackground(DriveActivity.java:371)
05-17 20:31:13.430: E/Decompress(27611):    at id.ac.petra.ta.DriveActivity$DownloadFile.doInBackground(DriveActivity.java:1)
05-17 20:31:13.430: E/Decompress(27611):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-17 20:31:13.430: E/Decompress(27611):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-17 20:31:13.430: E/Decompress(27611):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-17 20:31:13.430: E/Decompress(27611):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-17 20:31:13.430: E/Decompress(27611):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-17 20:31:13.430: E/Decompress(27611):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-17 20:31:13.430: E/Decompress(27611):    at java.lang.Thread.run(Thread.java:856)
05-17 20:31:13.430: E/Decompress(27611): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
05-17 20:31:13.430: E/Decompress(27611):    at libcore.io.Posix.open(Native Method)
05-17 20:31:13.430: E/Decompress(27611):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
05-17 20:31:13.430: E/Decompress(27611):    at libcore.io.IoBridge.open(IoBridge.java:400)
05-17 20:31:13.430: E/Decompress(27611):    ... 13 more

Do anyone knows what's this happening? Please help.

4

1 回答 1

1

The main cause of this error is because the folder/subfolder (unzipped/files) does not exist. So, the problem solved after I add these few lines:

java.io.File f = new java.io.File(_location + ze.getName());
f = new java.io.File(f.getParent());
f.mkdirs();
于 2013-05-17T14:10:38.117 回答